我正在忙于angular2 Web应用程序,我有一个选择html组合框,我正尝试将其绑定到一系列Active Stock Take对象。我的应用程序似乎可以编译,没有任何问题,但是出现以下运行时错误。知道这意味着什么吗?我会以错误的方式处理吗?使用可以安全导航吗?
我的错误:
zone.js:420
Unhandled Promise rejection:Cannot set property 'stack' of undefined; Zone:<root>; Task:Promise.then; Value:TypeError: Cannot set property 'stack' of undefined
at SyntaxError.set [as stack] (
http://localhost:4200/vendor.bundle.js:75980:61)
at assignAll (
http://localhost:4200/vendor.bundle.js:111629:29)
at SyntaxError.ZoneAwareError (
http://localhost:4200/vendor.bundle.js:111700:16)
at SyntaxError.BaseError [as constructor] (
http://localhost:4200/vendor.bundle.js:75942:16)
at new SyntaxError (
http://localhost:4200/vendor.bundle.js:6861:16)
at TemplateParser.parse (
http://localhost:4200/vendor.bundle.js:21436:19)
at JitCompiler._compileTemplate (
http://localhost:4200/vendor.bundle.js:55485:68)
at
http://localhost:4200/vendor.bundle.js:55368:62
at Set.forEach (native)
at JitCompiler._compileComponents (
http://localhost:4200/vendor.bundle.js:55368:19)
at createResult (
http://localhost:4200/vendor.bundle.js:55251:19)
at ZoneDelegate.invoke (
http://localhost:4200/vendor.bundle.js:111167:26)
at Zone.run (
http://localhost:4200/vendor.bundle.js:111038:43)
at
http://localhost:4200/vendor.bundle.js:111460:57
at ZoneDelegate.invokeTask (
http://localhost:4200/vendor.bundle.js:111200:35)
TypeError: Cannot set property 'stack' of undefined
at SyntaxError.set [as stack] (
http://localhost:4200/vendor.bundle.js:75980:61)
at assignAll (
http://localhost:4200/vendor.bundle.js:111629:29)
at SyntaxError.ZoneAwareError (
http://localhost:4200/vendor.bundle.js:111700:16)
at SyntaxError.BaseError [as constructor] (
http://localhost:4200/vendor.bundle.js:75942:16)
at new SyntaxError (
http://localhost:4200/vendor.bundle.js:6861:16)
at TemplateParser.parse (
http://localhost:4200/vendor.bundle.js:21436:19)
at JitCompiler._compileTemplate (
http://localhost:4200/vendor.bundle.js:55485:68)
at
http://localhost:4200/vendor.bundle.js:55368:62
at Set.forEach (native)
at JitCompiler._compileComponents (
http://localhost:4200/vendor.bundle.js:55368:19)
at createResult (
http://localhost:4200/vendor.bundle.js:55251:19)
at ZoneDelegate.invoke (
http://localhost:4200/vendor.bundle.js:111167:26)
at Zone.run (
http://localhost:4200/vendor.bundle.js:111038:43)
at
http://localhost:4200/vendor.bundle.js:111460:57
at ZoneDelegate.invokeTask (
http://localhost:4200/vendor.bundle.js:111200:35)
zone.js:422
list of 1 items
aaZoneAwareError{stack: "Error: Uncaught (in promise): TypeError: Cannot se…calhost:4200/vendor.bundle.js:111358:35) [<root>]", message: "Uncaught (in
promise): TypeError: Cannot set prope…http://localhost:4200/vendor.bundle.js:111200:35)", originalStack: "Error: Uncaught (in promise): TypeError: Cannot
se…http://localhost:4200/vendor.bundle.js:111358:35)", zoneAwareStack: "Error: Uncaught (in promise): TypeError: Cannot se…calhost:4200/vendor.bundl
我的html:
<select class="form-control" [(ngModel)]="activeStockTakes?">
<option *ngFor="let activeStockTake of activeStockTakes" [ngValue]="activeStockTake">{{activeStockTake.UserCode}} - {{activeStockTake.Comment}}
</option>
</select>
我的stock-takeComponent.ts的ngOninit:
this.restService.getActiveStockTakes()
.subscribe(
res => {
this.activeStockTakes = res;
console.log(this.activeStockTakes);
},
res => {
console.log(res);
}
);
}
?
在结尾处有多余的[(ngModel)]="activeStockTakes?"
的绑定ngModel
不能是用于生成<option>
元素的数组
[(ngModel)]="activeStockTakes"
应该是这样的
[(ngModel)]="selectedActiveStockTakes"
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句