From cd38cbf975b501d846e6149d1d993972a1af0053 Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Wed, 6 Jun 2012 15:54:40 -0700
Subject: feat(controller): support as instance syntax
Support ng-controller="MyController as my" syntax
which publishes the controller instance to the
current scope.
Also supports exporting a controller defined with route:
````javascript
angular.module('routes', [], function($routeProvider) {
$routeProvider.when('/home', {controller: 'Ctrl as home', templateUrl: '...'});
});
````
---
src/ng/directive/ngController.js | 73 ++++++++++++++++++++++++++++++++++++++--
src/ng/directive/ngView.js | 51 +++++++++++++++-------------
2 files changed, 99 insertions(+), 25 deletions(-)
(limited to 'src/ng/directive')
diff --git a/src/ng/directive/ngController.js b/src/ng/directive/ngController.js
index 438a0d87..be2f149f 100644
--- a/src/ng/directive/ngController.js
+++ b/src/ng/directive/ngController.js
@@ -21,7 +21,8 @@
* @scope
* @param {expression} ngController Name of a globally accessible constructor function or an
* {@link guide/expression expression} that on the current scope evaluates to a
- * constructor function.
+ * constructor function. The controller instance can further be published into the scope
+ * by adding `as localName` the controller name attribute.
*
* @example
* Here is a simple form for editing user contact information. Adding, removing, clearing, and
@@ -29,8 +30,75 @@
* 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.
+ * for a manual update. The example is included in two different declaration styles based on
+ * your style preferences.
+
+
+