0
剛開始使用angular2-seed應用的角度2:https://github.com/angular/angular2-seed。我創建了一個組件,但它不會顯示在頁面上,該組件坐落在一個目錄處於同一水平的部件叫做external_components:如何以角度2顯示組件?
import {Component} from 'angular2/core';
@Component({
selector: 'SiteQualification',
template: '<div>hello service external</div>',
})
export class SiteQualification {
constructor() {}
ngOnInit() {
}
}
這是種子app.ts:
import {Component} from 'angular2/core';
//import {Router, RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
import {Home} from './components/home/home';
import {About} from './components/about/about';
import {SiteQualification} from './external_components/sitequalification';
import {RepoBrowser} from './components/repo-browser/repo-browser';
@Component({
selector: 'seed-app',
providers: [],
pipes: [],
templateUrl: 'app/seed-app.html',
})
export class SeedApp {
constructor() {
}
}
在種子app.html我有:
<main>
<siteQualification></siteQualification>
</main>
這是app.ts:
import {bootstrap} from 'angular2/platform/browser';
import {provide} from 'angular2/core';
import {HTTP_PROVIDERS} from 'angular2/http';
import {ROUTER_PROVIDERS, LocationStrategy, HashLocationStrategy} from 'angular2/router';
import {SeedApp} from './app/seed-app';
bootstrap(SeedApp, [
HTTP_PROVIDERS,
ROUTER_PROVIDERS,
provide(LocationStrategy, {useClass: HashLocationStrategy})
])
.catch(err => console.error(err));
也刪除了路由器。 問題是組件不會顯示?我錯過了什麼?
是否有一個控制檯錯誤?你是否引導你的主應用程序? – echonax
選擇器是SiteQualification,標籤是siteQualification。這不是問題嗎? –
@echonax沒有控制檯錯誤 –