0

I have javascript code in a page inside my AngularJS app which I need to send a scope variable to it, so I was wondering if that is possible in AngularJS and if yes, how? Thanks

index.html:

<script>
  $(document).ready(function() { 
        var options = { 
            beforeSend: function(xhr){
                 xhr.setRequestHeader('Token', ###Need to pass scope var here### );
            }
        }; 
      ....
      ....
    }); 
</script>

    <div>
      <p>
          {{pageDescription}}
      </p>
    </div>
3
  • 4
    Why do you have this outside Angular? Either way, you can do angular.element(elemWithinScope).scope().variableNameHere; Commented Apr 2, 2014 at 15:57
  • @tymeJV Because I failed to find an appropriate way to post files in AngularJS as form data, made a lot of research, asked here before, tried many AngularJS modules but none worked, the only thing that worked smoothly without complications was JQuery :) Commented Apr 2, 2014 at 16:32
  • @tymeJV just tried angular.element('[ng-controller=clientController]').scope(). pageDescription; but it didn't work as I got error TypeError: Cannot read property 'pageDescription' of undefined, taken in consideration that pageDescription is defined in the controller as a variable Commented Apr 2, 2014 at 16:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.