Here's the fiddle http://jsfiddle.net/altermind/yak10smq/1/
I need to declare variable 'appetite' in the controller 'EntrynewCtrl', then pass it to the javascript function, something like that:
<script>
var a = appetite;
</script>
When I do "console.dir(scope);" I see in console:
$$childScopeClass
I can allocate that variable via console, but have no idea how to access it in the script.
UPD: gave wrong fiddle, now it's correct
Please try this,
angular.element('#YOUR-ELEMENT-SELECTOR').scope().$apply(function(scope){
scope.doStuff();
});
Another way,
angular.element('.ng-scope').each(function(e, t){
console.log(t,angular.element(t).scope());
});
you may need this tool AngularJS Batarang read this blog for more detail Debugging AngularJS Apps from the Console
angular.element(targetNode).scope()
-> ChildScope {$id: "005", this: ChildScope, $$listeners: Object, $$listenerCount: Object, $parent: Scope…}
angular.element(targetNode).isolateScope()
-> Scope {$id: "009", $$childTail: ChildScope, $$childHead: ChildScope, $$prevSibling: ChildScope, $$nextSibling: Scope…}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.