$ routeParams를 사용하여 URI에서 속성을 가져 와서 로컬 변수를 설정합니다.
typescripts 입력을 사용하여 $ routeParams 유형을 설정하면 $ routeParams에 액세스 할 수 없습니다.
어떻게 $ routeParams의 속성에 액세스 할 수 있습니까?
class Controller{
constructor($routeParams: ng.route.IRouteParamsService, private $location: ng.ILocationService)
this.propetry1 = this.getProperty1($routeParams.property1);
}
property1: string;
getProperty1(input: string):string{
return (input || "Not present");
}
}
ng.route.IRouteParamsService 코드는이 : 재산
'속성 1이 ng.route.IRouteParamsService의 종류에 존재하지 않는'interface IRouteParamsService {
[key: string]: any;
}
이것은 오류가
$ routeParams의 유형을 : any로 변경하면 property1이 올바르게 설정됩니다. $ routeParams의 속성을 계속 처리하면서 Typescript의 엄격한 입력을 유지하려면 어떻게해야합니까?