ng-model is not getting changed in ui-select

后端 未结 9 672
太阳男子
太阳男子 2021-01-17 08:45

I\'m trying to achieve something very straightforward:


    {         


        
相关标签:
9条回答
  • 2021-01-17 09:18

    some people here touched the problem but i'll make it clear. for some reason ui-select requires the ng-model to be a nested value within $scope. so ng-model must point to x.y within scope and not x or y.

    0 讨论(0)
  • 2021-01-17 09:18

    I'm struggling as well with a very basic use case, on Angular 1.2.16 and ui-select 0.8.3. Although it seems to me there's a typo in your code, in ui-select-match.

    Usually that attributes looks like {{$select.selected.your_property_here}}, so double curly braces and single dollar sign, for some kind of standard property name $select.selected. Could it be this is your issue?

    0 讨论(0)
  • 2021-01-17 09:19

    Not sure if you figured this out already, but I was also struggling with this "basic use case" today, being new to AngularJS and all. I'm using Angular 1.2.16 and ui-select 0.8.3, and while everything else worked, I just couldn't get it to update the scope variable employee.selected.

    In my case, the issue was caused by my limited experience with AngularJS. Since ng-model is set to a property of an object (employee, in my case) it had to be initialized first. Adding $scope.employee = {}; into the controller resolved this.

    0 讨论(0)
提交回复
热议问题