Html Angular 2第一个应用程序工作,第二个应用程序don';T

Html Angular 2第一个应用程序工作,第二个应用程序don';T,html,angular,Html,Angular,我试图创建一个加载两个组件的angular2应用程序。 第一个名为app的组件工作正常。 但是第二个组件没有(称为appsecond) index.html代码 <h1>Demo of Angular 2 using ASP.NET 5 with Visual Studio 2015</h1> <app>Loading...</app> <br /> <app-second>Loading...</app-secon

我试图创建一个加载两个组件的angular2应用程序。 第一个名为app的组件工作正常。 但是第二个组件没有(称为appsecond)

  • index.html代码

    <h1>Demo of Angular 2 using ASP.NET 5 with Visual Studio 2015</h1>
    <app>Loading...</app>
    <br />
    <app-second>Loading...</app-second>
    
        import {Component} from 'angular2/core';
    
        @Component({
                selector: 'app',
                template: 'My First Angular 2 App'
        })
    
        export class AppComponent {}
    
        import {Component} from 'angular2/core';
    
        @Component({
                selector: 'app-second',
                template: 'My First Angular 2 App'
        })
    
        export class AppSecondComponent{}
    
  • app-second.ts代码

    <h1>Demo of Angular 2 using ASP.NET 5 with Visual Studio 2015</h1>
    <app>Loading...</app>
    <br />
    <app-second>Loading...</app-second>
    
        import {Component} from 'angular2/core';
    
        @Component({
                selector: 'app',
                template: 'My First Angular 2 App'
        })
    
        export class AppComponent {}
    
        import {Component} from 'angular2/core';
    
        @Component({
                selector: 'app-second',
                template: 'My First Angular 2 App'
        })
    
        export class AppSecondComponent{}
    
  • 快照

有人能告诉我这里的错误是什么吗


Thanx.

您需要引导这两个组件

bootstrap(AppComponent, ...);
bootstrap(AppSecondComponent, ...);

您需要引导这两个组件

bootstrap(AppComponent, ...);
bootstrap(AppSecondComponent, ...);

你也需要启动你的第二个应用程序

//Importing bootstrap to instantiate your app
import {bootstrap} from 'angular2/platform/browser'

//importing the components you need to load
import {AppComponent} from './app/app'
import {AppSecondComponent} from './app/app-second'

//instantiating the components
bootstrap(AppComponent);
bootstrap(AppSecondComponent);

希望这能有所帮助。

您还需要启动第二个应用程序

//Importing bootstrap to instantiate your app
import {bootstrap} from 'angular2/platform/browser'

//importing the components you need to load
import {AppComponent} from './app/app'
import {AppSecondComponent} from './app/app-second'

//instantiating the components
bootstrap(AppComponent);
bootstrap(AppSecondComponent);

希望这能有所帮助。

您的问题缺少最重要的部分。如何初始化应用程序?您的问题中缺少最重要的部分。如何初始化应用程序?