javascript - Implement a logical part as Generic one in AngularsJs -


i have started working on angularjs in encountered case need guidance go through. implementing message section in application(asp net mvc - angularjs).currently have implemented message section specific module under particular ng-app , under particular ng-controller. need same functionality used inside module. it's duplicating same code again ng-app under ng-controller not approach. wanted , plug , play kind of approach angularjs code.

i have used 2 service,1 directive under particular ng-app , functions inside particular controller. want make these 1 common code , used inside under ng-app , ng-controller.

is possible? if how can achieve.

let me know if query unclear

you said used 2 service, 1 directive, , controller etc messaging feature. if want re-use across various applications, need bundle of module. example:

angular.module('custommessaging', [])   .controller('messagingctrl', function(messenger, messagemanager) {     ....   })   .directive('messagingdir', function() {     return {       controller: 'messagingctrl'         ...     }   })   .service('messenger', function() {     ...   })   .service('messagemanager', function() {     ...   }) 

now can specify dependency of of angular applications shown below access directive, services , controller anywhere in app:

angular.module('myfirstapp', ['custommessaging']); angular.module('mysecondapp', ['custommessaging']); 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -