Select multiple objects and save to ng-model

ⅰ亾dé卋堺 提交于 2019-12-06 14:17:59

ngOptions compares objects by strict equality, meaning your model group needs to be a reference to one of the group in $scope.groups:

function MyCtrl($scope) {

    $scope.test = "Das ist ein Test";
    $scope.groups = [{id: 142, name: 'Foo'},{id: 143, name: 'Bar'}, {id: 144, name: 'Bas'}];

    $scope.contact = {name: 'Bob', groups: [{id: 143}]};
    $scope.contact = {name: 'Bob', groups: $scope.groups[1]};
}

PLUNKER

Try using 'track by tracking_expression' into ngOptions (also run on ngRepeat) that allow match objects by expresion instead of reference. Angular Select Documentation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!