javascript - Is it possible to change Angular scope in jQuery event? -
thats code:
.directive('search', function($templaterequest, $compile) { return { link: function(scope, element, $scope){ $templaterequest('/js/angularjs/search.html').then(function(html){ var template = angular.element(html); element.append(template); $compile(template)(scope); $('#multipleselect').multipleselect({ test: console.log($scope), onclick: function(view, scope) { //view.checked ? scope.searchbytitle.multi.push(view.value) : scope.searchbytitle.multi.remove(view.value); console.log('scope:'); console.log($scope); } }); }); } }; });
i using plugin: http://wenzhixin.net.cn/p/multiple-select/docs/
i wanna achieve after change 1 of multiple select value, wanna push sth angularjs scope (bascially use onclick event). scope not accessible inside jquery function...
if have workaround idea this, i'd hear :p
onclick: function(view, scope) { var scope = angular.element($("#multipleselect")).scope(); view.checked ? scope.searchbytitle.multi.push(view.value) : scope.searchbytitle.multi.remove(view.value); }
thats solution managed find. works :)
Comments
Post a Comment