diff options
| author | basarat | 2013-10-16 12:13:54 +1100 | 
|---|---|---|
| committer | Pete Bacon Darwin | 2013-10-24 22:26:39 +0100 | 
| commit | 46d396df72aab0678eddc3d4aac02c4ba95ceef4 (patch) | |
| tree | 5355623b74f72190ce1bb3791bc89fcd8f290a7a | |
| parent | db9c6a3528e3307b1e320fd15b1341eb9b39e1b7 (diff) | |
| download | angular.js-46d396df72aab0678eddc3d4aac02c4ba95ceef4.tar.bz2 | |
docs(ngModelController): $parent can help isolate scope directives
| -rw-r--r-- | src/ng/directive/input.js | 13 | 
1 files changed, 7 insertions, 6 deletions
| diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index 6e4961f8..804a86c0 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -939,14 +939,14 @@ var VALID_CLASS = 'ng-valid',   * Note that if you have a directive with an isolated scope, you cannot require `ngModel`   * since the model value will be looked up on the isolated scope rather than the outer scope.   * When the directive updates the model value, calling `ngModel.$setViewValue()` the property - * on the outer scope will not be updated. + * on the outer scope will not be updated. However you can get around this by using $parent.   * - * Here is an example of this situation.  You'll notice that even though both 'input' and 'div' - * seem to be attached to the same model, they are not kept in synch. + * Here is an example of this situation.  You'll notice that the first div is not updating the input.  + * However the second div can update the input properly.   *   * <example module="badIsolatedDirective">      <file name="script.js"> -		angular.module('badIsolatedDirective', []).directive('bad', function() { +		angular.module('badIsolatedDirective', []).directive('isolate', function() {        return {          require: 'ngModel',          scope: { }, @@ -961,8 +961,9 @@ var VALID_CLASS = 'ng-valid',  		});      </file>      <file name="index.html"> -      <input ng-model="someModel"> -      <div bad ng-model="someModel"></div> +        <input ng-model="someModel"/> +        <div isolate ng-model="someModel"></div> +        <div isolate ng-model="$parent.someModel"></div>      </file>   * </example>   * | 
