mercredi 11 mars 2015

How to share code between multiple projects with angularJS


Vote count:

0




I was wondering what would be the best practice to share common libraries and own modules between multiple angularJS projects.


Let's assume that I'm working on two different projects. Both rely on libraries like angularJS, bootstrap etc.


I have a file structure like below:


So I was thinking about just creating another directory with all the shared components so that I get sth. like:



  • Shared

    • angular

    • bootstrap

    • module B



  • Project 1

  • Project 2


I have module B written like:



angular.module("moduleB", [])
.service("SB", [function () {/*functionality here*/}]);
.factory("FB", [function () {/*functionality here*/}]);


and would then include it in my Project 1/2 as dependency like:



angular.module("project1", ["moduleB"]);


to achieve this approach.


Would that be the best way? What could be an alternative?



asked 46 secs ago







How to share code between multiple projects with angularJS

Aucun commentaire:

Enregistrer un commentaire