Skip to content

Instantly share code, notes, and snippets.

@ysyun
Created April 14, 2013 12:41
Show Gist options
  • Select an option

  • Save ysyun/5382574 to your computer and use it in GitHub Desktop.

Select an option

Save ysyun/5382574 to your computer and use it in GitHub Desktop.
AngularJS bi-directional bindin between local property and parent scope property
/*
<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