-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Conversation
// look for those directives that are components | ||
var candidateDirectives = directives.filter(function(directiveInfo) { | ||
// components have controller, controllerAs and restrict:'E' compatible | ||
return directiveInfo.controller && directiveInfo.controllerAs && directiveInfo.restrict.indexOf('E') >= 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just check === 'E'
rather than indexOf('E')
I tried to add minErr, angular.mock.$ComponentControllerProvider = ['$compileProvider', function($compileProvider) {
var minErr = angular.$$minErr('$componentController');
return {
$get: ['$controller','$injector', function($controller,$injector) {
return function $componentController(componentName, locals, bindings, ident) {
// get all directives associated to the component name
var directives = $injector.get(componentName + 'Directive');
// look for those directives that are components
var candidateDirectives = directives.filter(function(directiveInfo) {
// components have controller, controllerAs and restrict:'E'
return directiveInfo.controller && directiveInfo.controllerAs && directiveInfo.restrict === 'E';
});
// check if valid directives found
if (candidateDirectives.length === 0) {
throw minErr('nocomp','No \'{0}\' component found', componentName);
}
if (candidateDirectives.length > 1) {
throw minErr('multicomp','Found {0} directive candidates for component \'{1}\'', candidateDirectives.length, componentName);
}
// get the info of the component
var directiveInfo = candidateDirectives[0];
return $controller(directiveInfo.controller, locals, bindings, ident || directiveInfo.controllerAs);
};
}]
};
}]; but I'm getting this error from
I have added the directory I ran out of time. ¿Any clue how to solve it? Thanks! PS: I did not pushed back the changes because are breaking check passes, but I can push them if you ask for it. |
Not sure what might be causing the issue. IF you push the changes (with |
… (fail due to TypeError: Cannot read property 'nocomp' of undefined) at /Users/drodenas/Projects/drpicox/angular.js/docs/config/processors/error-docs.js:43:76)
Thanks! |
I'll take a look now |
The problem is that we were not minifying the So looking at this again, I realise now that we don't use minErr in the rest of |
I will review and merge the rest of the PR without this last commit |
No problem at all, I used throw new Error in the first approach because is what I found inside the angular-mock.js code. Thanks! |
See PR: #13732
See Issue: #13683
Now
$componentController
looks for the directive that represents a component which is the one that satisfies:Tests are added to evaluate under multiple scenarios commented in the original thread.
PS: I created the new PR to solve conflicts with minimum "dirtiness".