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を使用するほうが簡単でしょう。
'ブートストラップ(...)'のようにどのように見えるんで、あなたの他の質問で問題を修正
AppComponent
にプロバイダから
Location
を削除しますか? –"bootstrap(AppComponent);"のようになります。 – ehrt1974