angularjs: $scope update when I change a select with jQuery

前端 未结 5 2001
感动是毒
感动是毒 2020-12-09 05:30

I\'m using a jQuery plugin to \'customize\' my selects.

This plugin fires the change event of the original select when some option is selected.

The problem i

5条回答
  •  自闭症患者
    2020-12-09 05:53

    You need to access the scope of the dropdown and then apply it as shown below:

    $('button').on('click', function(){
        var newVal = $(this).data('val');
        $('select').val(newVal).change();
    
        var scope = angular.element($("select")).scope();
        scope.$apply(function(){
            scope.selectValue = newVal;
        });
    });
    

提交回复
热议问题