繁体   English   中英

多选不突出显示项目

[英]Multiple select not highlighting items

我添加了全选按钮以进行多项选择。 问题是如果我点击全选按钮,所有项目都会被选中但不会突出显示。

这是我的代码:

<div class="label_hd">Profiles* {{user.profile}}
    <input type="button" id="select_all" ng-click="selectedAll()"
           name="select_all" value="Select All" style="margin-left: 10px">
</div>
<select multiple class="browser-default" name="userprofile"
        id="userprofile" ng-model="user.profile">
    <option ng-repeat="profile in userprofiles" value="{{profile.profile}}">
        {{ profile.profile_name }}
    </option>
</select>

Controller.js代码:

$scope.selectedAll = function(){
    $scope.user.profile = []; 
    angular.forEach($scope.userprofiles, function(item){
       $scope.user.profile.push( item.profile);
    }); 
}

需要设置$ scope.user.profile [item] = true;

$scope.selectedAll = function(){
$scope.user.profile = []; 
angular.forEach($scope.userprofiles, function(item){
    $scope.user.profile.push( item.profile.toString());
    $scope.user.profile[item] = true;
}); 
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM