javascript - How to compile html outside of ng-app scope after partial update -
i have user-control uses anguar.js
, declares div
ng-app
somewhere inside. other part of system doesn't use angular.js
, doesn't reference it.
now, problem after partial update of html (using update-panel, instance) need recompile (because it's injected dom) , cannot technically this, far whole html ng-app
declaration being replaced.
and not have access $compile
service (okay, can using $injector
, $scope
?)
function afterpartialupdate(containerelement) { var injector = angular.injector(['ng']); injector.invoke(function($compile) { $compile(containerelement)( ???need scope, lost ); }); };
i can store scope @ moment of initial page-load in global variable. recompiling using same scope results in incremental increase of $$watchers
collection , other unwanted side-effects...
i guess there should way force angular execute same javascript executes during intial page-load, i.e. create modules, traverse html, instantiate controllers, etc?
injector provides $rootscope service. try use compile element:
var injector = angular.injector(['ng']); injector.invoke(function($compile, $rootscope) { $compile(containerelement)($rootscope); });
Comments
Post a Comment