javascript - Angularjs: inject Controller on module inside anonymous function -
i bit newbiew javascript
, starting use angular.js
so question if there way inject controller inside module declared in anonymous function
my code looks
app.js
(function(angular) { var app = angular.module('organizer', ['ngmaterial', 'nganimate', 'ngaria']); })(angular);
sitecontroller.js
(function(angular, app) { app.controller('site', function($scope, $mddialog) { var alert = $mddialog.alert({ title: 'test', content: 'testing', ok: 'exit' }); $mddialog.show(alert); }); })(angular);
i have tried ways if possible, still see if here explain how can made if could.
note: have used angular.js
before , wanted try different way declare controllers client wont have way modify it
if create module in angular, can not obfuscate in way. in console, user can run angular.module('organizer')
access app, , call method want on it.
the reason code won't work written, because not passing app
variable anonymous function. if want add controller organizer
module, this:
(function(angular) { angular. module('organizer'). controller('site', function($scope, $mddialog) { ... }); })(angular);
Comments
Post a Comment