2016-10-31 8 views
2

小さなAngular2アプリケーションの主なコンポーネントでこのエラーが発生しています。現在、私のコードは次のとおりです:Angular2 DartでLocationStrategyエラーメッセージのプロバイダがありません

@Component(
    selector: 'my-app', 
    styleUrls: const ['app_component.css'], 
    templateUrl: 'app_component.html', 
    directives: const[ROUTER_DIRECTIVES], 
    providers: const[ClientService, Location]) 
class AppComponent implements OnInit { 
    final ClientService _clientService; 

    Client client; 
    final Location _location; 

    AppComponent(this._clientService, this._location); 

    @override 
    ngOnInit() async { 
    var components = _location.path().split('/').skip(1).toList(); 
    if (components.isEmpty) return; 
    if (components.first=="client" && components.length==2) { 
     client = await _clientService.getById(components.skip(1).first); 
    } 
    } 
} 

angular2の現在のブラウザの場所を知る方法はありますか? window.locationを使用するほうが簡単でしょう。

+0

'ブートストラップ(...)'のようにどのように見えるんで、あなたの他の質問で問題を修正AppComponent

bootstrap(AppComponent, [ ROUTER_PROVIDERS, 

にプロバイダからLocationを削除しますか? –

+0

"bootstrap(AppComponent);"のようになります。 – ehrt1974

答えて

2

bootstrap(...)ROUTER_PROVIDERSを追加し、これはおそらくもRouteParams

+0

ありがとうございました! – ehrt1974

関連する問題