Skip to content

Instantly share code, notes, and snippets.

@MathRobin
Created May 31, 2019 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MathRobin/d3f332df73857e5edb4450776cbf8cd7 to your computer and use it in GitHub Desktop.
Save MathRobin/d3f332df73857e5edb4450776cbf8cd7 to your computer and use it in GitHub Desktop.
angularjs isolateApp
.directive('isolateApp', function ($injector, $interval, User) {
return {
scope: {},
restrict: 'E',
compile: function (element, attrs) {
var html = element.html();
element.html('');
return function (scope, element) {
scope.$destroy();
var newRoot = document.createElement('div');
newRoot.innerHTML = html;
angular.bootstrap(newRoot, [attrs['app']]);
element.append(newRoot);
$interval.cancel(checkLazyIsLoaded);
};
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment