0

I an new to angular and was wandering about the following issue:

Suppose I want to provide some UI functionality, like a plugin, that uses angular and uses other angular modules on its own (like the https://github.com/angular-ui/ui-router for example).

I am trying to figure out what would be the minimal requirements (changes required) from the hosting HTML page to be able to use my new directive (assuming a directive is the right way to wrap up such UI functionality.

So I know I will need to obviously include angular.js in the main html page, and also need to add ng-app to some element (that is an ancestor/container of the element with my new directive) at the HTML. I will also need to include some JS in which I will implement the directive as part of my module.

If the page already has an ng-app that it creates inside it, then it can probably just add my module as a dependency of its existing App (module).

Now what happens if I want to use another module within my module?

Does it mean that the main HTML page needs to know it an include the JS with the "3rd party" or my own sub/helper module? or is there some what my own module would load the JS's its dependent on?

It is of course possible that I am not thinking of this properly... feel free to guide me...

Davin Tryon
  • 66,517
  • 15
  • 143
  • 132
epeleg
  • 10,347
  • 17
  • 101
  • 151

1 Answers1

0

Does it mean that the main HTML page needs to know it an include the JS with the "3rd party" or my own sub/helper module? or is there some what my own module would load the JS's its dependent on?

Yes and no.

Yes, the "3rd party" library must be included somewhere, but not necessarily in the HTML file.

It can be included in your own html (The Twitter Bootstrap library, for instance, throws an error if the user did not included jQuery) or it can be wrapped by your own library (via ajax call, copy-paste minified version, etc. More details here).

Community
  • 1
  • 1
Beterraba
  • 6,515
  • 1
  • 26
  • 33
  • Is there a best-practice for how to do this in angular? I mean so that if two components need the same version of some library - it is not loaded twice? – epeleg Feb 17 '14 at 14:00