简体   繁体   中英

Multiple select not highlighting items

I have added select all button to multiple select. Problem is that all the items are getting selected but not getting highlighted if I click on select all button.

Here's my code:

<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 code:

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

Need to set $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;
}); 
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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