AngularJS: directive adding ng:model
by vojtajina
HTML
<script src="http://ci.angularjs.org/job/angular.js-angular-master/161/artifact/build/pkg/0.10.6-871252ab/angular-0.10.6-871252ab.js" ng:autobind></script>
<input type="text" data-ido="value" />
value={{value}}
JavaScript
angular.directive('data-ido', function(expression, template) {
template.attr('ng:model', expression).
// remove, so that we don't call it again :-D
removeAttr('data-ido');
// compile it again, now without data-ido directive,
// but this type, input will take the new ng:model value
var linker = this.compile(template);
return function() {
linker(this);
};
});