Skip to content

Instantly share code, notes, and snippets.

@ysyun

ysyun/drink.js

Created Apr 14, 2013
Embed
What would you like to do?
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