I am inserting angular template to element. Consider following example,
<p>
<c ng-controller="ctrl">
...
</c>
</p>
if I remove c from javascript. What will be side effects? (scope leaks) How to avoid this?
I have used this,
function render() {
var lastScope = angular.element('c').scope();
if(lastScope) {
lastScope.$destroy();
}
$('c').remove();
getTemplate(context + '/c.html', function(template) {
if (template) {
angular.element(document).injector().invoke(['$compile', '$rootScope', function($compile, $rootScope) {
$('p').append($compile(template)($rootScope));
$rootScope.$apply();
}]);
}
});
}
when I click tab render function get called everytime. Any other sugestions?