angularjs - Angular 2-way binding in ng-repeat -
i'm trying update values in ng-repeat ng-bind (or double curly braces) , html5's contenteditable.
i cannot double binding work. don;t think contenteditable issue since doesn't work either input fields.
<div ng-controller="myctrl"> <ul><li ng-repeat="sequence in sequences" sv-element> <span class="flex1" contenteditable="true" ng-bind="sequence.sequencetext"></span> // <span contenteditable="true">{{sequence.sequencetext}}</span> </li></ul> {{sequences}} </div>
well didn't want use directive did. nice , easy:
app.directive('contenteditable', function() { return { require: 'ngmodel', link: function(scope, element, attrs, ctrl) { // view -> model element.bind('blur', function() { scope.$apply(function() { ctrl.$setviewvalue(element.html()); }); }); // model -> view ctrl.$render = function() { element.html(ctrl.$viewvalue); }; // load init value dom ctrl.$render(); } }; });
Comments
Post a Comment