zoukankan      html  css  js  c++  java
  • Angular之替换根组件

    一 在index.html中,替换根组件选择器

    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>Angular4ReactiveForm</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-hero-list></app-hero-list>
    </body>
    </html>

    二 在根模块的注解中,替换根组件

    import { BrowserModule } from '@angular/platform-browser';
    import { ReactiveFormsModule } from '@angular/forms';
    import { NgModule } from '@angular/core';
    
    
    import { HeroListComponent } from './hero-list/hero-list.component';
    import { HeroDetailComponent } from './hero-detail/hero-detail.component';
    
    
    @NgModule({
      declarations: [
        HeroListComponent,
        HeroDetailComponent
      ],
      imports: [
        BrowserModule,
        ReactiveFormsModule
      ],
      providers: [],
      bootstrap: [HeroListComponent]
    })
    export class AppModule { }

    三 如果浏览器控制台没有报错 ( The selector "app-hero-list" did not match any elements ),并编译、运行,则替换成功。 

  • 相关阅读:
    Mybatis插件开发入门,运行原理,例子
    ActiveMQ是什么,为什么使用MQ
    sql优化
    用户注册流程
    JMS入门Demo
    运维自动化之Ansible
    ceph安装部署
    ceph工作原理
    linux进程
    任务计划
  • 原文地址:https://www.cnblogs.com/sea-breeze/p/8944246.html
Copyright © 2011-2022 走看看