I found some a template, and in reviewing it, discovered that the var anApp is declared once in app.js, and is subsequently shared by all modules. My questions are: 1. Will using a single variable cause all angular components to get stored in the global scope? 2. Is this an anti-pattern, or an ok design pattern?
---app.js----
var anApp = angular.module("myApp", [
"ui.router",
"ui.bootstrap",
"oc.lazyLoad",
"ngSanitize"
]);
anApp.config(['$ocLazyLoadProvider', function($ocLazyLoadProvider) {...}]);
---controllers.js---
anApp.controller('fooCtrl', ['$scope', function($scope) {...}]);
---directives.js---
anApp.directive('ngSpinnerBar', ['$rootScope',function($rootScope) {...}]);
etc.
Aucun commentaire:
Enregistrer un commentaire