ngProgress
ngProgress copied to clipboard
provide destory instance method
Hi. Every time i make a new instance of progress bar a new scope is made for it. But it never gets destroyed. This can cause memory leaks. Can you do something about it or at least point me in the right direction? I looked at the code and can't get a grasp of this concept of creating a scope in a service then compiling a directive with it.
+1
@tiberiu80,
You can reuse the same progress bar by wrapping it in a service, so you don't need to create multiple progress bars. This way you can inject the same instance in multiple controllers/directives.
An example service:
app.factory("progressBar", ['ngProgressFactory', function(ngProgressFactory) {
var progressBar = ngProgressFactory.createInstance();
progressBar.setColor("#008cba");
return progressBar;
}
]);
Then you can inject this into a controller/directive:
app.controller("exampleController", ["$scope", "progressBar", function(scope, progressBar) {
progressBar.start();
progressBar.complete();
});