前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Angular bootstrap的一个例子

Angular bootstrap的一个例子

作者头像
Jerry Wang
发布2020-08-11 15:57:57
3940
发布2020-08-11 15:57:57
举报

A way to initialize and launch an app or system. In Angular, an app’s root NgModule (AppModule) has a bootstrap property that identifies the app’s top-level components.

例子:

代码语言:javascript
复制
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

其中bootstrap属性的值AppComponent来自文件app.component.ts:

During the bootstrap process, Angular creates and inserts these components into the index.html host web page.

index.html的内容:

代码语言:javascript
复制
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>MyFirstProject</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
  <app-root></app-root>
</body>
</html>

这个app-root的标签:

定义在app.component.ts的Component selector里:

要获取更多Jerry的原创文章,请关注公众号"汪子熙"

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-08-10 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档