Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

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.

share|improve this question
    
did you try var v=angular.element("#id").scope() , then i think you can use list as v.list inside your javascript function – shreya Jun 7 '15 at 6:11
    
#id.. Not clear which id to be considered. I am using ng-view and route binds html and controller. – Shiva Kodityala Jun 7 '15 at 16:26
    
Can you please create jsfiddle for above question. – shreya Jun 7 '15 at 16:29

Why not just instantiate JustGage in your controller and add it to the scope?

share|improve this answer
    
Or be even more Angularly and wrap it in a directive. – Andy Gaskell Jun 7 '15 at 4:51
    
Or what Andy said. You should always think directives or filters in most cases. – Jeffrey A. Gochin Jun 7 '15 at 4:56
    
Good question, but it should have been a comment. It is not answering the asked question – n00b Jun 7 '15 at 5:36
    
Sometimes, a question can be an answer. In this case a prompt I'll admit. – Jeffrey A. Gochin Jun 7 '15 at 5:56
    
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. – Nikolay Kostov Jun 7 '15 at 7:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.