如何将select值转为UI值select值?
how to select value in UI select value?
你能告诉我如何在 UI-select 值中 select 值吗?
实际上,当用户 select 我想要 select age 的任何名称时。这是我的代码
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>
示例
当我selectAmaliemultipleDemo模型值为12
或者如果我 select Wladimir 是模型值“30”..
它是多个 selected 所以模型应该是数组 ..
我们可以这样做吗?
ui-select
的方式已经设计好了,需要ng-model
的值变成object
。这里你给了一个原始类型
代码
$scope.model = {multipleDemo :[]};
HTML
<ui-select tagging tagging-label="new tag" multiple ng-model="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.age as color in people | filter:$select.search">
{{color.name}}
</ui-select-choices>
</ui-select>
<p>Selected: {{test.multipleDemo}}</p>
UI 更改 只需在 ui-select
上添加 on-select="OnClickSelect($item)"
和 on-remove="OnRemoveSelect($item)"
<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>
Angular 更改 在 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);
}
你能告诉我如何在 UI-select 值中 select 值吗?
实际上,当用户 select 我想要 select age 的任何名称时。这是我的代码 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>
示例
当我selectAmaliemultipleDemo模型值为12 或者如果我 select Wladimir 是模型值“30”.. 它是多个 selected 所以模型应该是数组 ..
我们可以这样做吗?
ui-select
的方式已经设计好了,需要ng-model
的值变成object
。这里你给了一个原始类型
代码
$scope.model = {multipleDemo :[]};
HTML
<ui-select tagging tagging-label="new tag" multiple ng-model="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.age as color in people | filter:$select.search">
{{color.name}}
</ui-select-choices>
</ui-select>
<p>Selected: {{test.multipleDemo}}</p>
UI 更改 只需在 ui-select
on-select="OnClickSelect($item)"
和 on-remove="OnRemoveSelect($item)"
<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>
Angular 更改 在 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);
}