0

I have included the angular js in my project and written a function name "hasOrganizationPermission" like below . And I am calling this function from some other project but this project does not contains any angular code or reference.

Note: We all know that, there are lots of questions and answers available in StackOverflow for this question but all answers are given by using angular js reference only. I am asking without angular help, how we can call a angular js function from pure Javascript

 app.factory('$user', function ($http, $cookies, $q, $injector, $authMgr) {
   function PlatformUser(sessionUser) {
     var user = this;

   user.hasOrganizationPermission = function (action, organizationId) {
       if (!action) return false;
       var actionId = typeof action == 'object' ? action.id : action;
       //Some Logics & return....
   };
  }
 });

Here I want to call the function "hasOrganizationPermission" from Jquery or Javascript without using any angular reference. So how to call the function from pure java script? Is it possible to call a angular js function from pure javascript ?

2 Answers 2

1

If your function logic depends on any angular property, it is not possible because, read this. If not depends on angular property, create your function as global function and call from any where!

Sign up to request clarification or add additional context in comments.

Comments

1

Your best bet would be to extract this function out of angular and into an external function. This way you will be able to call it from angular and from your non-angular code.

1 Comment

So you mean, other than extract this function out, we cannot call this function from javascript?

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.