Closed ghost closed 10 years ago
I agree with this, If I'm to use classy in everything I should just be able to add it as a dependancy inside of my app.js and not have to require it in every individual controller, its not DRY!
Is this a good reason not to do this?
Can you give me a code example for this please?
angular.module('baseModule', ['ui.router', 'classy', 'firstModule])
.config(function($stateProvider) {
$stateProvider
.state('first', {
url: '/first',
controller: 'firstCtrl',
template: '<h1> Hello World</h1>
})
})
// This will not work because firstModule doesn't have the classy dependency
angular.module('firstModule', [])
.classy.controller({
name: 'firstCtrl',
inject: ['$scope'],
})
Basically my hope is that if you inject classy into the baseModule
it would not needed to be included in every new module for controllers.
Is the code from the second snippet supposed to include baseModule
as a require:
// This will not work because firstModule doesn't have the classy dependency
angular.module('firstModule', ['baseModule'])
.classy.controller({
name: 'firstCtrl',
inject: ['$scope'],
})
@MikaAK: Ok, I see what you mean now. I think I would prefer to keep it explicit rather than introduce logic which would make it implicit.
I actually think @bwu-aa's original issue was different so I will keep this issue open. I believe @bwu-aa's issue was with code like this:
angular.module('baseModule', ['classy']);
angular.module('anotherModule', ['baseModule']).classy; // Doesn't work
Yes, that's what I mean. Thanks. (this is my another account for bwu-aa which is used in my company, sorry for this.)
Fixed in beta 5
If I my parent angular module depends on 'classy', I don't want my child modules also depends on 'classy'. It repeats the code, doesn't make sense at all.