Angular组件和模块之间有什么区别 [英] What's the difference between an Angular component and module

查看:147
本文介绍了Angular组件和模块之间有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在观看视频和阅读文章,但是这篇特定文章使我如此感到困惑,在文章开头说

I've been watching videos and reading articles but this specific article make me so confused, at the start of the article it says

Angular中的应用程序遵循模块化结构. Angular应用程序将包含许多模块,每个模块专门用于单一用途.通常,模块是一组内聚的代码,与其他模块集成在一起以运行Angular应用.

The applications in Angular follow modular structure. The Angular apps will contain many modules, each dedicated to the single purpose. Typically module is a cohesive group of code which is integrated with the other modules to run your Angular apps.

模块从其代码中导出一些类,函数和值. 该组件是Angular的基本模块,多个组件将构成您的应用程序.

A module exports some classes, function and values from its code. The Component is a fundamental block of Angular and multiple components will make up your application.

一个模块可以是另一个模块的库.例如,作为主要Angular库模块的angular2/core库将由另一个组件导入.

A module can be a library for another module. For instance, the angular2/core library which is a primary Angular library module will be imported by another component.

它们是可互换的条款吗?组件是模块吗?但是反之亦然吗?

Are they exchangeable terms? Is a component a module? But not viceversa?

推荐答案

组件控制视图(html).它们还与其他组件和服务进行通信,以为您的应用程序带来功能.

Components control views (html). They also communicate with other components and services to bring functionality to your app.

模块由一个或多个组件组成.他们不控制任何HTML.您的模块声明哪些组件可以由属于 other 模块的组件使用,哪些类将由依赖项注入器注入,哪些组件将被引导.模块使您可以管理组件,从而为您的应用程序带来模块化.

Modules consist of one or more components. They do not control any html. Your modules declare which components can be used by components belonging to other modules, which classes will be injected by the dependency injector and which component gets bootstrapped. Modules allow you to manage your components to bring modularity to your app.

这篇关于Angular组件和模块之间有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆