javascript - ng-bind but store internal value -


some server side code (gsp) generating html me so:

<span>     <g:generateamount /> </span> 

i'm wrapping in angular controller , want able bind scope variable span:

<span ng-bind="subtotal">     <g:generateamount /> </span> 

problem is, after binding, inner text removed because subtotal isn't set in controller on initialization (although writing controller works fine). ng-model doesn't seem read either.

question

is there way bind node persist data inside node? instance, in above example, $scope.subtotal equal whatever <g:generateamount /> outputs. able update subtotal controller , have changes reflected.

see example: http://jsfiddle.net/robcampo/zg6ge/2/

just create custom directive , value dom before $compile.

alternatively can change generated html , put <g:generateamount /> ng-init attribute, like

 <div ng-controller="myctrl" ng-init="subtotal=<g:generateamount>">     <span ng-bind="subtotal" />  </div> 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -