Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

feat($controller): throw error when requested controller is not regis… #15015

Merged
merged 4 commits into from
Aug 12, 2016

Conversation

Narretz
Copy link
Contributor

@Narretz Narretz commented Aug 11, 2016

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
docs

What is the current behavior? (You can also link to an open issue here)
when a requested controller is not found (not registered), then a pretty non-descriptive ng:areq error is thrown

What is the new behavior (if this is a feature change)?
a new error is thrown

Please check if the PR fulfills these requirements

Other information:

…tered

Previously, it would throw the ng:areq error, which is less
specific and just informs that the requested controller did
not yield a function. Given how commonly controllers are used
in Angular, it makes sense to have a specific error.

The ng:areq error is still thrown when the registered controller
is not a function.

Closes #14980

…tered

Previously, it would throw the ng:areq error, which is less
specific and just informs that the requested controller did
not yield a function. Given how commonly controllers are used
in Angular, it makes sense to have a specific error.

The ng:areq error is still thrown when the registered controller
is not a function.

Closes angular#14980
@nikhilknoldus
Copy link

Hey @Narretz thanks for including #14980


This error occurs when the {@link ng.$controller `$controller()`} service is called
with a string that does not match any of the registered controllers. The controller service may have
been invoked directly, or indirectly through the {@link ng.ngController `ngController`} directive,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add "for example through...", because the list is non-exhaustive.
(E.g. a route definitions for ngRoute or ui.router and possibly ngMaterial instantiate controllers as well under the hood.)

@gkalpak
Copy link
Member

gkalpak commented Aug 12, 2016

A couple of minor comments.
LGTM otherwise 👍

@Narretz
Copy link
Contributor Author

Narretz commented Aug 12, 2016

I've made the changes you noted, and also removed the test for ngController. As the $controller service can be used by many different services, we would have to test all of them, which is tedious duplication.

@gkalpak
Copy link
Member

gkalpak commented Aug 12, 2016

LGTM

@Narretz Narretz merged commit eacfe41 into angular:master Aug 12, 2016
Narretz added a commit that referenced this pull request Aug 17, 2016
Previously, it would throw the ng:areq error, which is less
specific and just informs that the requested controller is not defined. 
Given how commonly controllers are used
in Angular, it makes sense to have a specific error.

The ng:areq error is still thrown when the registered controller
is not a function.

Closes #14980
PR (#15015)
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
Previously, it would throw the ng:areq error, which is less
specific and just informs that the requested controller is not defined. 
Given how commonly controllers are used
in Angular, it makes sense to have a specific error.

The ng:areq error is still thrown when the registered controller
is not a function.

Closes angular#14980
PR (angular#15015)
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
Previously, it would throw the ng:areq error, which is less
specific and just informs that the requested controller is not defined.
Given how commonly controllers are used
in Angular, it makes sense to have a specific error.

The ng:areq error is still thrown when the registered controller
is not a function.

Closes angular#14980
PR (angular#15015)
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
Previously, it would throw the ng:areq error, which is less
specific and just informs that the requested controller is not defined.
Given how commonly controllers are used
in Angular, it makes sense to have a specific error.

The ng:areq error is still thrown when the registered controller
is not a function.

Closes angular#14980
PR (angular#15015)
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
Previously, it would throw the ng:areq error, which is less
specific and just informs that the requested controller is not defined. 
Given how commonly controllers are used
in Angular, it makes sense to have a specific error.

The ng:areq error is still thrown when the registered controller
is not a function.

Closes angular#14980
PR (angular#15015)
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
Previously, it would throw the ng:areq error, which is less
specific and just informs that the requested controller is not defined.
Given how commonly controllers are used
in Angular, it makes sense to have a specific error.

The ng:areq error is still thrown when the registered controller
is not a function.

Closes angular#14980
PR (angular#15015)
petebacondarwin pushed a commit that referenced this pull request Nov 23, 2016
Previously, it would throw the ng:areq error, which is less
specific and just informs that the requested controller is not defined.
Given how commonly controllers are used
in Angular, it makes sense to have a specific error.

The ng:areq error is still thrown when the registered controller
is not a function.

Closes #14980
PR (#15015)
petebacondarwin pushed a commit that referenced this pull request Nov 24, 2016
Previously, it would throw the ng:areq error, which is less
specific and just informs that the requested controller is not defined.
Given how commonly controllers are used
in Angular, it makes sense to have a specific error.

The ng:areq error is still thrown when the registered controller
is not a function.

Closes #14980
PR (#15015)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants