NgModule

Posted lvsk

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了NgModule相关的知识,希望对你有一定的参考价值。

/*这些是javascript导入语句。angular对此一无所知。*/

import { BrowserModule } from ‘@angular/platform-browser‘;
import { NgModule } from ‘@angular/core‘;
  import { FrameworkComponent } from ‘./framework.component‘;
import { AppComponent } from ‘./app.component‘;

/*@NgModule装饰器让Angular知道这是一个NgModule。*/

@NgModule({
  declarations: [  /*要把模块的类列在 @NgModule.declarations 列表中。*/
    AppComponent
  ],
  // declarations 的子集,可用于其它模块的组件模板
    exports: [FrameworkComponent],
  imports: [     /* 这些是NgModule导入 */
    BrowserModule
  ],
  providers: [], /*可以把使用的服务加到 @NgModule.providers列表中*/
  bootstrap: [AppComponent] // 根组件
})
export class AppModule { }

// declarations 数组告诉 Angular 哪些组件属于该模块。declarations 数组只能接受可声明对象。可声明对象包括组件、指令和管道。

 

以上是关于NgModule的主要内容,如果未能解决你的问题,请参考以下文章