您能告诉我如何在UI选择值中选择值吗?
实际上,当用户选择任何名称时,我想选择商品的年龄。这是我的代码http://plnkr.co/edit/InxOyQRjrlrDJtx2VuzI?p=preview
<ui-select tagging tagging-label="new tag" multiple ng-model="multipleDemo" theme="select2" ng-disabled="disabled" style="width: 300px;">
<ui-select-match placeholder="Select colors...">{{$item.name}}</ui-select-match>
<ui-select-choices repeat="color in people | filter:$select.search">
{{color.name}}
</ui-select-choices>
</ui-select>
例子
当我选择Amalie multipleDemo模型值是12或如果我选择Wladimir是模型值“ 30” ..它是多重选择的,因此模型应该是数组..
我们能做到吗?
只需添加on-select="OnClickSelect($item)"
并继续on-remove="OnRemoveSelect($item)"
进行UI更改ui-select
<ui-select tagging tagging-label="new tag" multiple ng-model="multipleDemo"
on-select="OnClickSelect($item)" on-remove="OnRemoveSelect($item)"
theme="select2" ng-disabled="disabled" style="width: 300px;">
<ui-select-match placeholder="Select colors...">{{$item.name}}</ui-select-match>
<ui-select-choices repeat="color in people | filter:$select.search">
{{color.name}}
</ui-select-choices>
</ui-select>
<p>Selected: {{multipleDemo}}</p>
角度变化将这些功能添加到内部controller
$scope.OnClickSelect=function(item) {
$scope.multipleDemo.push(item.age)
}
$scope.OnRemoveSelect = function(item) {
var index = $scope.multipleDemo.indexOf(item.age);
$scope.multipleDemo.splice(index, 1);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句