javascript - Issue with ng-repeat after calling $compile to bind dynamic HTML in angular -
i'm building application has multiple tabs containing html generated dynamically. clicking tab calls .net mvc controller render razor view, return html angular , display in body of tab.
the body of tab needs bound underlying angular model. i'm not sure if best way it, have far, works:
function updatehtml(html, tabid) { angular.element(document.getelementbyid('tabbodycontainer')).html(html); $scope.currenttab = tabid; var fnlink = $compile(document.getelementbyid('tabbodycontainer')); // returns link function used bind template scope fnlink($scope); }
this works great except when click on tab has repeater. first tab has repeater renders fine on load because first tab generated on page load razor view engine , bound. when click different tab , click back, rows in repeater missing, if repeater didn't bind or dom never updated section after $compile.
any ideas? or there better way this?
thanks!
i worked out - caching html called mvc controller once per tab. html first tab being cached after angular had been bound, meaning html added on tab 1 post compile html. html fine, repeaters, angular replaces markup comments before, meaning if cache html won't know supposed repeated next time insert html , run $compile
Comments
Post a Comment