angularjs - How do I access my angular scope from jQuery dialog buttons? -
http://plnkr.co/edit/rf0vitthvbg6j0z7kudo
i'm using jquery dialog , want use dialog buttons, don't know how @ scope trigger (currently non-existent) $http or $resource call server updated model when jquery dialog button clicked. feel if i'm going wrong, don't know direction go here.
you can use angular functions find scope attached element , call function on it.  prefer abstract away , find root of ng-app , broadcast event app outside-code doesn't know specifics of inside code except event broadcast.
angular.$externalbroadcast = function (selector, event, message) {     var scope = angular.element(selector).scope();      scope.$apply(function () {         scope.$broadcast(event, message);     }); };   then, code, can call like:
angular.$externalbroadcast('#app-container', 'dosomething', parameters);   and inside app, i'd this:
$rootscope.$on('dosomething', function(parameters) {     // handle external event. });   if don't approach, scope:
var scope = angular.element(selector).scope();   and it.  make sure call scope.$apply or else digestion cycle won't happen.
Comments
Post a Comment