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
2 Answers 2
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());
});
Sign up to request clarification or add additional context in comments.
Comments
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...}
Comments
lang-js
appetiteand you want to access it, wouldn't it just bevar a = scope.appetite;?