Skip to content

Instantly share code, notes, and snippets.

@tb
Forked from mattlanham/x-editable angularjs directive
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tb/5e8a79f52cbbf6f7637b to your computer and use it in GitHub Desktop.
Save tb/5e8a79f52cbbf6f7637b to your computer and use it in GitHub Desktop.
(function() {
"use strict";
angular.module("editableModule", ['ng']).directive("editable", function($timeout) {
return {
restrict: "AE",
scope: true,
require:"ngModel",
link: function(scope, element, attrs, ngModel) {
element.editable({
success: function(response, newValue) {
$timeout(function() {
ngModel.$setViewValue(newValue);
ngModel.$render();
});
}
});
scope.$watch(attrs.ngModel, function(newValue) {
element.editable('setValue', newValue);
});
}
};
});
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment