loading two components in angular2 non SPA

后端 未结 2 1691
你的背包
你的背包 2021-01-23 13:19

Given the following components. I want to use these components on a non SPA web site exactly like the plunker here. This sample is no longer valid, as the latest beta of angular

2条回答
  •  萌比男神i
    2021-01-23 13:44

    Seems you are missing a module definition e.g.:

    app.module.ts

    import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    
    import {Comp1} from './comp1';
    import {Comp2} from './comp2';
    
    @NgModule({
        imports: [
            BrowserModule
        ],
        declarations: [
            Comp1,
            Comp2
        ],
        bootstrap: [Comp1]
    })
    
    export class AppModule { }
    

    main.ts

    import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
    
    import { AppModule } from './app.module';
    
    platformBrowserDynamic().bootstrapModule(AppModule);
    

提交回复
热议问题