I have a list of values in $scope from a controller. Need to access those in a non-angular javascript function.
I have a route like:
.when("/display", {
templateUrl: "html/display.html",
controller: "DisplayController"
})
In display.html, I have the following javascript function. I have number of them, in fact
<script>
var g = new JustGage({
id: "gauge",
value: 67,
min: 0,
max: 100,
title: "Visitors"
});
</script>
In above function, value need to be passed from a list variable in $scope from angular DisplayController.
How do I do it? How do I specify the values which are in $scope.list?
I have seen other questions in similar lines.. Proposed solution are like doing something like
angular.element(myDomElement).scope()
I am using ng-view and not actually specifying any controller in any of the elements. In this case, is it ng-view element?
Any help is appreciated.
-
did you try var v=angular.element("#id").scope() , then i think you can use list as v.list inside your javascript functionshreyansh– shreyansh2015年06月07日 06:11:03 +00:00Commented Jun 7, 2015 at 6:11
-
#id.. Not clear which id to be considered. I am using ng-view and route binds html and controller.Shiva Kodityala– Shiva Kodityala2015年06月07日 16:26:44 +00:00Commented Jun 7, 2015 at 16:26
-
Can you please create jsfiddle for above question.shreyansh– shreyansh2015年06月07日 16:29:32 +00:00Commented Jun 7, 2015 at 16:29
1 Answer 1
Why not just instantiate JustGage in your controller and add it to the scope?