看到这个 plunk
我想在 input
上使用对象模型(用于与 angularui bootstrap typeahead 交互)。从预先输入的内容中选择内容时,它工作得很好,但在加载时显示 [object Object]
如何获取输入以在加载时显示模型对象的属性?
最佳答案
以防万一其他人像我一样登陆这里,拥有 [object Object]
显示在某些输入中...
就我而言,我将 form
命名为与模型属性同名的元素,如下所示:
<form name="contact">
<input type="text" ng-model="contact.name" />
<input type="text" ng-model="contact.email" />
</form>
要么改变表格
name
为不同的名称,或更改型号名称。随着 Angular 填充
$scope
具有与 form
同名的属性,它会覆盖模型实例!
关于加载时的 angularjs 值不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15977327/