What's the difference between an Angular component and module

前端 未结 7 1735
春和景丽
春和景丽 2020-12-22 14:51

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

The applications in An

7条回答
  •  春和景丽
    2020-12-22 15:29

    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 { }
    

提交回复
热议问题