2
我试图实现MeanStack项目,当我试图打按钮更新我得到这个错误: 错误:请求的路径包含未定义的段索引1AngularJS 2错误未定义的索引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);
});
}
你不需要在router.navigate呼叫斜线 - 应该是:this.router.navigate([ '位置',ID]); – danimal