Created
April 14, 2013 12:41
-
-
Save ysyun/5382574 to your computer and use it in GitHub Desktop.
AngularJS bi-directional bindin between local property and parent scope property
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| <div ng-app="drinkApp"> | |
| <div ng-controller="AppCtrl"> | |
| Ctrl | |
| <input type="text" ng-model="ctrlFlavor"> | |
| Dir | |
| <div drink flavor="ctrlFlavor"></div> | |
| </div> | |
| </div> | |
| */ | |
| var app = angular.module("drinkApp", []); | |
| app.controller("AppCtrl", function($scope) { | |
| $scope.ctrlFlavor = "blackberry"; | |
| }) | |
| app.directive("drink", function() { | |
| return { | |
| scope: { | |
| flavor: "=" | |
| }, | |
| template: '<input type="text" ng-model="flavor"> ' | |
| } | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment