我是 AngularJS 2 的新手,这是我第一次尝试用 TSlint 编译它。我做了《英雄之旅》教程,有一个像下面这样的部分,TSlint 不想编译说object access via string literals is disallowed.
ngOnInit(): void {
this.route.params.forEach((params: Params) => {
let id = +params['id'];
this.projectService.getProject(id)
.then(project => this.project = project);
});
}
我不确定我是否理解这个问题,如果要解决它,我会迷失方向。请问你能帮帮我吗?
我的其他代码
getProjects(): Promise<Project[]> {
return this.http.get(`${this.configuration.Server}projects${this.configuration.ApiUrl}`)
.toPromise()
.then(response => response.json())
.catch(this.handleError);
}
getProject(ident: number): Promise<Project> {
return this.getProjects()
.then(projects => projects.find(project => project.id === id));
}