Angular bootstrap的一个例子
2023-09-14 09:04:03 时间
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.
例子:
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的内容:
<!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的原创文章,请关注公众号"汪子熙":
相关文章
- 【Angular专题】——(2)【译】Angular中的ForwardRef
- [Angular] Implement a custom form component by using control value accessor
- [Angular 2] Rendering an Observable with the Async Pipe
- [Angular-Scaled Web] 6. Navigating between states with ui-router
- [AngularJS] Using angular.bootstrap to Initialize Your App
- [Angular Directive] 2. Add Inputs to Angular 2 Directives
- [Angular 2] Share Template Content In Another Template With Content Projection <ng-content>
- [AngularJS] angular-formly: Extending Types
- Angular-Bootstrap和Compiler
- Angular应用bootstrap时的version检测机制
- 关于 Angular 工程文件 angular.json 里的 inlineCritical 属性
- 关于调用 Angular 属性指令 attribute Directive 是否需要带中括号的问题
- Angular 动态控制 aside 标签显示和隐藏的一个例子
- Angular应用input和div标签页的动态创建场景
- Angular应用里的Template Reference变量