Can someone help me understand how to inject a custom directive into a controller and call the functions show() and hide()? I keep getting the following error:
Error: [$injector:unpr] Unknown provider: inputThrobberProvider <- inputThrobber <- landingCtrl
Here is the example code:
var app = angular.module('myapp', ['ngAnimate', 'ui.router', 'templates']);
app.directive('inputThrobber', [function() {
return {
restrict: 'A',
require: 'ngModel',
controller: function($scope, $element) {
var inputThrobberCtrl = {
show: function() {
$element.addClass('throbbing');
},
hide: function() {
$element.removeClass('throbbing');
}
};
return inputThrobberCtrl;
}
};
}])
.controller('landingCtrl', ['$scope', 'geolocation', 'inputThrobber', function($scope, geolocation, inputThrobber) {
// inputThrobber.show()
geolocation.getAddress().then(function(address) {
$scope.address = address;
}).catch(function(err) {
$scope.error = error;
$scope.address = '';
})
.finally(function() {
// $inputThrobber.hide()
});
}]);