0

I am using ui select in my demo .I am using $scope.$apply() to update the view but it not working.

  • I have few option in my UI multiple select.There is one condition when user select Nicole it blank or remove previous selected value and set only Nicole value in model.
  • here is my plunker

http://plnkr.co/edit/eVXVzlRXJ4KUZaNjID6P?p=preview

Step to reproduce

  • select Amalie from drop down .so model value is 12
  • then select Nicole from drop down .So I remove all previous value from model so now model value only 43 .But it not remove Amelia from view why ? I used $scope.$apply also.

    $scope.OnClickSelect = function(item, $select) {
        if ($scope.restrictNames.indexOf(item.name) != -1) {
            $scope.multipleDemo = [];
            $scope.$apply();
            $scope.multipleDemo.push(item.age);
        } else {
            if ($scope.multipleDemo.indexOf(43) != -1) {
                $select.selected = [];
    
            } else {
                $scope.multipleDemo.push(item.age);
            }
        }
    
    }
    
6
  • look at the first part in this section github.com/angular-ui/ui-select/wiki/FAQs Commented Sep 29, 2016 at 21:46
  • and here stackoverflow.com/a/29907853/736967 Commented Sep 29, 2016 at 21:48
  • $scope.$apply is not running because the digest cycle was already running....Also...the component you are using is for adding tags, why would you use tags to remove them? why not some sort of dropdown? check the js file for the component, maybe is not allowing you to play around with something is not intended for that? Commented Sep 29, 2016 at 22:04
  • please share any fiddle Commented Sep 30, 2016 at 0:17
  • can you tell us what you want to achieve leaving $apply() aside for a while , and why is there a specific cond for Nicole and Amaile.Is that your requirement? Commented Sep 30, 2016 at 6:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.