Skip to content

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 angular#4409
1 parent 261057d commit bf29cbc

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/ng/directive/ngController.js

Lines changed: 4 additions & 1 deletion
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)