In angularjs, given a module, how do you check if a directive/controller exists given a module.
I have a module and I want to know if some particular directives have bee
I found some working code here
angular.service('ControllerChecker', ['$controller', function($controller) {
return {
exists: function(controllerName) {
if(typeof window[controllerName] == 'function') {
return true;
}
try {
$controller(controllerName);
return true;
} catch (error) {
return !(error instanceof TypeError);
}
}
};
}]);
JSFiddle: http://jsfiddle.net/fracz/HB7LU/6780/