Is it better to automate @register() ?
Excellent library! Thank you for sharing :)
Question: Would it make sense to automate the @register() method? Unless I misunderstand, it seems that in most applications, nearly all controllers will likely call the @register() method the same way?
myApp = angular.module('myApp',[])
class @ExampleCtrl extends @RangCtrl
@register myApp # <- always the same for a given application
Wouldn't it make sense if myApp was defined globally...maybe like so...
angular
.module('myApp.constants',[])
.constant(
"APP":
"NAME": "myApp"
"VERSION": "1234"
...
)
and @RangCtrl's constructor did something like this...
constructor: (args...) ->
name ?= @name || @toString().match(/function\s*(.*?)\(/)?[1]
$window[APP.NAME].controller name, @ # <- automatic registration
...
I guess this would require that rang is set up as a factory or ``provider` so that it can accept dependency injection? Not sure how that would work?
Thanks for commenting you're the first ! It's a good idea. I want to implement convention over configuration feature, with possibility to override it. What about
@Rang.config
app_name: 'myPersonalized'
template_url: 'personaliezed/template/path'
Good idea, i like that approach!
Hihi ! I have push some new code and update readme. Tell me what do think about.
So after few days. Because directive force me to write register at the end of file. I have starting to rethink the overall register concept. I a have write https://github.com/ranska/aether for it. AEther is batch coffeescript class meta programming and batch call methods lib. Yup !
So now AEther will inject @register and call it just after app definition. THis is so cool i have spend lot off time to try meta progamming coffee and learn a lot.