각도 컴포넌트와 모듈의 차이점
나는 비디오를보고 기사를 읽었지만이 특정 기사 는 기사의 시작 부분에서 나를 혼란스럽게 만듭니다.
Angular의 응용 프로그램은 모듈 식 구조를 따릅니다. Angular 앱에는 각각 단일 용도 전용 모듈이 많이 있습니다. 일반적으로 모듈은 다른 모듈과 통합되어 Angular 앱을 실행하는 응집력있는 코드 그룹입니다.
모듈은 코드에서 일부 클래스, 함수 및 값을 내 보냅니다. 구성 요소는 Angular의 기본 블록이며 여러 구성 요소가 응용 프로그램을 구성합니다.
모듈은 다른 모듈의 라이브러리 일 수 있습니다. 예를 들어, 기본 Angular 라이브러리 모듈 인 angular2 / core 라이브러리는 다른 구성 요소에서 가져옵니다.
교환 가능한 조건입니까? 구성 요소가 모듈입니까? 그러나 그 반대는 아닌가?
구성 요소 제어보기 (html). 또한 다른 구성 요소 및 서비스와 통신하여 앱에 기능을 제공합니다.
모듈은 하나 이상의 구성 요소로 구성됩니다. 그들은 HTML을 제어하지 않습니다. 모듈은 다른 모듈에 속하는 구성 요소가 사용할 수있는 구성 요소 , 종속성 인젝터에 의해 주입되는 클래스 및 부트 스트랩되는 구성 요소를 선언 합니다. 모듈을 사용하면 구성 요소를 관리하여 앱에 모듈성을 제공 할 수 있습니다.
글쎄, 답변을 게시하기에는 너무 늦었지만 easy
초보자가 누구인지 이해하는 것이 좋을 것 같습니다 Angular
. 프레젠테이션 중에 제공하는 예 중 하나입니다.
앵귤러 어플리케이션을로 간주하십시오 Building
. 건물에는 N
여러 개의 건물이있을 수 Apartments
있습니다. 는 Apartment
로 간주됩니다 Module
. 아파트는 라는 이름의 Angular 응용 프로그램의 빌딩 블록에 해당하는 N
번호를 가질 수 있습니다 .rooms
Components
이제 각 Apartment (Module)
것 Rooms (Components)
, Lifts (Services)
,와 아파트에서 큰 움직임을 가능하게 Wires (Pipes)
주변 정보를 이동하고 아파트에 유용 할 수 있습니다.
또한 swimming pool, tennis court
모든 건물 거주자가 공유하는 장소가 있습니다 . 따라서 이것들은 SharedModule 내부의 컴포넌트로 간주 될 수 있습니다.
기본적으로 차이점은 다음과 같습니다.
내 슬라이드를 따라 Angular 응용 프로그램 의 빌딩 블록 을 이해하십시오.
가장 간단한 설명 :
Module is like a big container containing one or many small containers called Component, Service, Pipe
A Component contains :
HTML template or HTML code
Code(TypeScript)
Service: It is a reusable code that is shared by the Components so that rewriting of code is not required
Pipe: It takes in data as input and transforms it to the desired output
.
Angular Component
A component is one of the basic building blocks of an Angular app. An app can have more than one component. In a normal app, a component contains an HTML view page class file, a class file that controls the behaviour of the HTML page and the CSS/scss file to style your HTML view. A component can be created using @Component
decorator that is part of @angular/core
module.
import { Component } from '@angular/core';
and to create a component
@Component({selector: 'greet', template: 'Hello {{name}}!'})
class Greet {
name: string = 'World';
}
To create a component or angular app here is the tutorial
Angular Module
An angular module is set of angular basic building blocks like component, directives, services etc. An app can have more than one module.
A module can be created using @NgModule
decorator.
@NgModule({
imports: [ BrowserModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
A module in Angular 2 is something which is made from components, directives, services etc. One or many modules combine to make an Application. Modules breakup application into logical pieces of code. Each module performs a single task.
Components in Angular 2 are classes where you write your logic for the page you want to display. Components control the view (html). Components communicate with other components and services.
Component is the template(view) + a class (Typescript code) containing some logic for the view + metadata(to tell angular about from where to get data it needs to display the template)
.
basically group the related components, services together
독립적 인 기능을 수행 할 수있는 모듈 . 예를 들어, 앱에는 대시 보드와 같이 앱의 특정 기능에 대한 구성 요소를 그룹화하기위한 기능에 대한 모듈이있을 수 있습니다.이 모듈은 다른 애플리케이션에서 간단히 잡고 사용할 수 있습니다.
'IT' 카테고리의 다른 글
“com.google.firebase.provider.FirebaseInitProvider”클래스를 찾지 못했습니까? (0) | 2020.06.24 |
---|---|
HTML5 양식 유효성 검사 기본 오류 메시지를 어떻게 변경하거나 제거 할 수 있습니까? (0) | 2020.06.23 |
Objective-C 2.0에서 메소드를 더 이상 사용되지 않는 것으로 플래그 지정하려면 어떻게합니까? (0) | 2020.06.23 |
배열에서 가장 가까운 숫자를 얻습니다 (0) | 2020.06.23 |
매개 변수로서 Objective-C 패스 블록 (0) | 2020.06.23 |