Closed
Description
I'm trying to make everything in my app a component(directive), and resolve as much as possible in the ui-router state, to ensure the component has all it needs when the state is loaded.
This is an example of what I'm referring to:
.state('my-state', {
template: '<my-component data="ctrl.data" type="ctrl.type"></my-component>',
resolve: {
data: function($http) {
return $http.get('/api/getMyData');
},
type: function(myService) {
return myService.getType();
}
},
controller: function(data, type) {
this.data = data;
this.type = type;
},
controllerAs: 'ctrl'
});
I find my self needing to repeat the this.data = data
, this.type = type
parts for almost all my states.
I think that supporting a bindToController
option, that will insert resolved data in the controller will be helpful here, similar to a directive's definition object.
What do you guys think? if this sounds right I can even try to implement it, as it looks like a simple addition.