javascript - ngModel does not update parent object -


i try make directive using requires ngmodel manage coords object ({x: number, y: number}).

my problem when update value of in directive, works fine directive, parent scope data comes not updated.

in directive here content of link function (only part manages ngmodel) :

ngmodel.$render = function() {     console.log('render');     scope.top = ngmodel.$viewvalue.top;     scope.left = ngmodel.$viewvalue.left; };  // transform model value view value // have x, y coords (of center) , need transform them top, left position ngmodel.$formatters.push(function(modelvalue) {     console.log('> view');     if (modelvalue) {         return {             top: modelvalue.y - scope.pointer.size / 2,             left: modelvalue.x - scope.pointer.size / 2         };     }      return modelvalue; });  // transform view value model value // have top, left position , need transform them x, y coords (of center) ngmodel.$parsers.push(function(viewvalue) {     console.log('> model');     if (viewvalue) {         return {             x: viewvalue.left + (scope.pointer.size / 2),             y: viewvalue.top + (scope.pointer.size / 2)         };     }      return viewvalue; });  

there drag'n'drop feature changes $viewvalue , propagate (when element dropped) :

scope.$apply(function () {     ngmodel.$setviewvalue({         top: scope.top,         left: scope.left     }); }); 

and directive call in parent :

<img-pointer data-ng-repeat="answer in graphicquestionctrl.answer"              data-ng-model="answer"> </img-pointer> 

the value in graphicquestionctrl.answer seems never updated.

i have removed isolated scope directive img-pointer have read blocks update of parent, not fix problem.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -