Reputation: 40649
I'm trying to get access to the dom element ($element) from the controller, but get an 'unknown provider' error (Unknown provider: $elementProvider <- $element)
Here's the code:
CatalogController = function($scope, $state,$http,$element) {
console.log('CatalogController',$scope.$id,'parent:',$scope.$parent.$id);
}
appModule.config(function($stateProvider) {
$stateProvider.state('catalog1', {
url: '/catalog',
views: {
'catview':{
templateUrl: 'partials/catalog.html',
controller: [ '$scope', '$state','$http','$element',CatalogController ]
}
}
});
})
The injection of $http is fine.
Any ideas?
Upvotes: 3
Views: 2285
Reputation: 40649
I'm glad to announce that the folks at ui-router accepted my change/pull request as well as my explanations for the reason. injection of an element and attr is officially supported: https://github.com/angular-ui/ui-router/tree/master/src
I'd like to thank everyone who's been involved in this lively discussion
EDIT: more than a year later, it seems that it was accepted: https://github.com/angular-ui/ui-router/issues/1657
Upvotes: 2