Angular: Empty Fiddle
http://angularjs.org/
by provegard
HTML
<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div ng-controller="MyCtrl">
<input type="text" ng-model="foo" foobar>
<div>{{foo}}</div>
</div>
JavaScript
var myApp = angular.module('myApp',[]);
myApp.
directive('foobar', function() {
return {
restrict: 'A', // only activate on element attribute
require: '?ngModel', // get a hold of NgModelController
link: function(scope, element, attrs, ngModel) {
if(!ngModel) return; // do nothing if no ng-model
// Specify how UI should be updated
//ngModel.$render = function() {
// alert(ngModel.$modelValue);
//};
ngModel.$setViewValue = function(value) {
ngModel.$viewValue = value;
ngModel.$modelValue = value + "-model";
};
}
};
});
function MyCtrl($scope, $http) {
//$scope.foo = "200000000";
}