Created
May 31, 2019 11:51
-
-
Save MathRobin/d3f332df73857e5edb4450776cbf8cd7 to your computer and use it in GitHub Desktop.
angularjs isolateApp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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