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

Commit bf29cbc

Browse files
tylermcginnispetebacondarwin
authored andcommitted
docs(ngController): do not attach a controller twice
A common mistake for beginners is to attach a controller in both the $routeProvider and also in the html document using the ng-controller directive. This change highlights this, to help prevent developers from doing so in the future. Closes #4409
1 parent 261057d commit bf29cbc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/ng/directive/ngController.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
* * Controller — The `ngController` directive specifies a Controller class; the class contains business
1717
* logic behind the application to decorate the scope with functions and values
1818
*
19-
* Note that an alternative way to define controllers is via the {@link ngRoute.$route $route} service.
19+
* Note that you can also attach controllers to the DOM by declaring it in a route definition
20+
* via the {@link ngRoute.$route $route} service. A common mistake is to declare the controller
21+
* again using `ng-controller` in the template itself. This will cause the controller to be attached
22+
* and executed twice.
2023
*
2124
* @element ANY
2225
* @scope

0 commit comments

Comments
 (0)