Angular: 27205559
http://angularjs.org/
by Oli Gustafsson
HTML
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.min.js"></script>
<div ng-controller="MyCtrl">
<input type="text" add-model="{{myModel}}" />
<br />
<br />{{testModel}}</div>
JavaScript
var myApp = angular.module('myApp', []);
myApp.directive('addModel', function ($compile) {
return {
restrict: 'A',
link: function (scope, element, attrs, ctrl) {
var model = attrs.addModel;
element.attr('ng-model', model);
element.removeAttr('add-model'); // avoid infinite loop
$compile(element)(scope);
}
};
});
myApp.controller('MyCtrl', function ($scope) {
$scope.myModel = 'testModel';
$scope.testModel = 'text';
});