It is not possible to completely eliminate the impact of JavaScript once it has been executed as it becomes integrated into the environment. One workaround is to use an iframe to create a separate isolated environment that doesn't have direct access to your main page. Alternatively, if you simply want to run scripts consecutively, you can store them in an array and utilize ng-repeat to dynamically create new script tags each time (JSBIN):
<h3>A Demo to Dynamically Add/Remove Javascript with AngularJS</h3>
<button ng-click="setScript(one)">One</button>
<button ng-click="setScript(two)">Two</button>
<button ng-click="setScript(three)">Three</button>
<script ng-repeat="script in scripts" ng-bind-html="script"></script>
<script>
var app = angular.module('app', ['ngSanitize']);
app.controller('mainController', function($scope){
$scope.scripts = [];
$scope.one = "alert('one')";
$scope.two = "alert('two')";
$scope.three = "alert('three')";
$scope.script = '';
$scope.setScript = function(script) {
$scope.scripts = [script];
}
});
</script>