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

docs(ngController): Add in more description of controller as #7591

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/ng/directive/ngController.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,17 @@
* @example
* Here is a simple form for editing user contact information. Adding, removing, clearing, and
* greeting are methods declared on the controller (see source tab). These methods can
* easily be called from the angular markup. Notice that the scope becomes the `this` for the
* controller's instance. This allows for easy access to the view data from the controller. Also
* notice that any changes to the data are automatically reflected in the View without the need
* for a manual update. The example is shown in two different declaration styles you may use
* according to preference.
* easily be called from the angular markup. Any changes to the data are automatically reflected
* in the View without the need for a manual update.
*
* Two different declaration styles are included below: one which injects `scope` into the
Copy link
Contributor

Choose a reason for hiding this comment

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

should be "injects $scope", no?

* controller, and another which instead binds methods and properties directly onto the controller
* using `this`. The first option is more common in the Angular community, and is generally used
* in boilerplates and in this guide. However, there are advantages to binding properties directly
* to the controller and avoiding scope. Using `controller as` makes it obvious which controller
* you are accessing in the template when multiple controllers apply to an element. Since there
* is always a `.` in the bindings, you don't have to worry about prototypal inheritance masking
* primitives.
<example>
<file name="index.html">
<script>
Expand Down