Inject $element in controller?


#1

Hey, how to inject $element from controller?

angular.module('xyz')
.controller('ArticlesCtrl', function ($element) {
console.log($element);
});

Cause error:

Error: [$injector:unpr] Unknown provider: $elementProvider <- $element <- ArticlesCtrl
http://errors.angularjs.org/1.3.13/$injector/unpr?p0=%24elementProvider%20%3C-%20%24element%20%3C-%20ArticlesCtrl
    at REGEX_STRING_REGEXP (file:///android_asset/www/lib/ionic/release/js/ionic.bundle.js:8890:12)
    at file:///android_asset/www/lib/ionic/release/js/ionic.bundle.js:12824:19
    at Object.getService [as get] (file:///android_asset/www/lib/ionic/release/js/ionic.bundle.js:12971:39)
    at file:///android_asset/www/lib/ionic/release/js/ionic.bundle.js:12829:45
    at getService (file:///android_asset/www/lib/ionic/release/js/ionic.bundle.js:12971:39)
    at invoke (file:///android_asset/www/lib/ionic/release/js/ionic.bundle.js:13003:13)
    at Object.instantiate (file:///android_asset/www/lib/ionic/release/js/ionic.bundle.js:13020:27)
    at file:///android_asset/www/lib/ionic/release/js/ionic.bundle.js:17289:28
    at IonicModule.controller.self.appendViewElement (file:///android_asset/www/lib/ionic/release/js/ionic.bundle.js:48436:24)
    at Object.IonicModule.factory.ionicViewSwitcher.create.switcher.render (file:///android_asset/www/lib/ionic/release/js/ionic.bundle.js:46630:41) 

#2

same issue. Did you get the solution? If yes then please share…


#3

var element = angular.element($(‘ion-view[nav-view=“active”]’, ‘ion-nav-view[name=“menuContent”]’))

so ugly code, it was my solution.


#4

I have this error

Error: [$injector:unpr] Unknown provider: $elementProvider <- $element <- perfilEstudiante

This is my code

`perfilEstudiante.$inject = ['$scope', 'obtenerPerfilEstu', '$element'];

    function perfilEstudiante($scope, obtenerPerfilEstu, $element) {
      //do stuff

    };`