2016-07-08 7 views
0

私はそれが期待されるコンポーネントを表示していない非常に単純なAngular 2アプリケーションを持っています。ルータコンセントコンポーネントの外にコンポーネントを表示できますか?ログインコンポーネントが表示されることはありませんが角2 - ルーターアウトレットの上にコンポーネントを表示

私app.component.htmlは...

<login></login> 
<router-outlet></router-outlet> 

次のようになります。 ルータコンセントに表示されているコンポーネントの1つの中に入れた場合に表示されます。

角度2でこれを行うことができますか、私のデザインを変更する必要がありますか?

マイapp.component.tsはこのようになります...

import {Component} from '@angular/core'; 
import { HTTP_PROVIDERS } from '@angular/http'; 
import 'rxjs/Rx'; 
import {ROUTER_DIRECTIVES } from '@angular/router'; 

import { TilesService } from '../app/shared/services/tiles.service' 
import { LocationService } from '../app/shared/services/location.service' 

import {LoginComponent} from '../app/shared/login/login.component' 

@Component({ 
    selector: 'tc-app', 
    template: require('./app.component.html'), 
    styles: [require('./app.component.scss').toString(), 
      require('../../public/scss/styles.scss').toString() 
    ], 

    directives: [ROUTER_DIRECTIVES], 
    providers: [HTTP_PROVIDERS, 
       TilesService, 
       LocationService, 
       LoginComponent 
       ] 
}) 

export class AppComponent { pageTitle: string = 'TileCase'; } 
+1

あなたの質問には、について多くを示していませんあなたのデザイン。これはもちろん働きます。 –

+1

app.component.tsコードを追加しました。他に何を見たいですか? –

答えて

2

あなたはディレクティブアレイへLoginComponentを追加する必要があります。

@Component({ 
    selector: 'tc-app', 
    template: require('./app.component.html'), 
    styles: [require('./app.component.scss').toString(), 
     require('../../public/scss/styles.scss').toString() 
    ], 

    directives: [ROUTER_DIRECTIVES, LoginComponent], 
    providers: [ 
     HTTP_PROVIDERS, 
     TilesService, 
     LocationService 
    ] 
}) 
+0

ああそうです、私は誤ってプロバイダに追加しました。ありがとう。 –

関連する問題