Skip to content

Instantly share code, notes, and snippets.

@ArtemAvramenko
Created April 1, 2015 20:32
Show Gist options
  • Save ArtemAvramenko/28143cee2e11f56e15d8 to your computer and use it in GitHub Desktop.
Save ArtemAvramenko/28143cee2e11f56e15d8 to your computer and use it in GitHub Desktop.
angular
.module("DemoApp", [])
.controller("DemoController", DemoController)
.config(["$provide", $provide =>
{
$provide.decorator("ngModelDirective", ["$delegate", $delegate =>
{
var directive = <angular.IDirective>$delegate[0];
var oldCompile = directive.compile;
directive.compile = (element, attr, trans) =>
{
var result = oldCompile(element, attr, trans);
var oldPre = result.pre;
result.pre = (scope, element, attr, ctrls, trans) =>
{
ctrls[2] = ctrls[2] || {};
var options = ctrls[2].$options || {};
ctrls[2].$options = options;
if (options.getterSetter === undefined)
{
options.getterSetter = true;
}
if (options.updateOnDefault === undefined && options.updateOn === undefined)
{
options.updateOnDefault = true;
}
return oldPre(scope, element, attr, ctrls, trans);
};
return result;
};
return $delegate;
}]);
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment