AngularJS – How can I create a new, isolated scope programmatically?

You can create a new scope manually.

You can create a new scope from $rootScope if you inject it, or just from your controller scope – this shouldn’t matter as you’ll be making it isolated.

var alertScope = $scope.$new(true);
alertScope.title="Hello";

AlertFactory.open(alertScope);

The key here is passing true to $new, which accepts one parameter for isolate, which avoids inheriting scope from the parent.

More information can be found at:
http://docs.angularjs.org/api/ng.$rootScope.Scope#$new

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)