AngularJS 2 错误未定义索引 1
AngularJS 2 Error undefined index1
我正在尝试实现一个 MeanStack 项目,当我尝试点击更新按钮时出现此错误:
错误:请求的路径在索引 1
处包含未定义的段
有更新服务
updateLocation(id, data) {
return new Promise((resolve, reject) => {
this.http.put('https://exemple.herokuapp.com/api/A/'+id, data)
.map(res => res.json())
.subscribe(res => {
resolve(res);
}, (err) => {
reject(err);
});
});
}
html
<form (submit)="onEditSubmit()">
和 component.ts
onEditSubmit() {
this.locationService.updateLocation(this.id,this.location).then((result) => {
let id = result['_id'];
this.router.navigate(['locations/', id]);
}, (err) => {
console.log(err);
});
}
将this.router.navigate(['locations/', id]);
替换为this.router.navigate(['/locations', id]);
我正在尝试实现一个 MeanStack 项目,当我尝试点击更新按钮时出现此错误: 错误:请求的路径在索引 1
处包含未定义的段有更新服务
updateLocation(id, data) {
return new Promise((resolve, reject) => {
this.http.put('https://exemple.herokuapp.com/api/A/'+id, data)
.map(res => res.json())
.subscribe(res => {
resolve(res);
}, (err) => {
reject(err);
});
});
}
html
<form (submit)="onEditSubmit()">
和 component.ts
onEditSubmit() {
this.locationService.updateLocation(this.id,this.location).then((result) => {
let id = result['_id'];
this.router.navigate(['locations/', id]);
}, (err) => {
console.log(err);
});
}
将this.router.navigate(['locations/', id]);
替换为this.router.navigate(['/locations', id]);