正如我的问题的标题所暗示的,我在NgRepeat中使用了Angular Bootstrap DualListbox,但没有任何运气让NgModel正常工作。让我试着来模仿我在下面做什么...NgModel NgRepeat与Angular Bootstrap DualListbox
ctrl.js
...
$scope.things = mySvc.things;
$scope.vals = mySvc.vals;
...
$scope.selectedVals = [];
$scope.doStuff = function (aThing) {
$http.post(aUrl, { thing: aThing, val = $scope.selectedVals[0].Value })
.success(function() {
...
})
.error(function() {
...
});
};
tmp.html
...
<header ng-repeat-start="thing in things">
{{thing.Name}}
</header>
<select
ng-model="selectedVals"
ng-options="val.Value for val in vals"
multiple
bs-duallistbox
>
</select>
<button type="button" class="btn-lg" ng-click="doStuff(thing.Name)">Do Stuff</button>
<br ng-repeat-end />
我的问题是,我不能让$scope.selectedVals
回暖从Angular Bootstrap DualListbox中进行选择。我的$scope.doStuff
函数正在调用,thing.Name
值正确传递,但我在控制台TypeError: Cannot read property 'Value' of undefined
中看到错误。此外,我可以通过控制台日志记录看到$scope.selectedVals
实际上是空的。
我有一个或多或少相同的设置工作在我的网络应用程序的其他部分,但它不存在于一个NgRepeat,所以我不得不认为这是问题。此外,我还看过一些关于NgRepeat中NgModel的问题的其他文章(请参阅:here,here,here和here),但我无法弄清楚它们与解决特定问题的方法有何关系有。
任何人都可以指出我做错了什么?
如果你是g如果你能对我的问题投下赞成票,如果你至少可以对我能做些什么使它更有用提出建设性的批评会是有帮助的。 – 2014-10-03 14:57:43