2016-10-31 2 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

관련 문제