ngProgress icon indicating copy to clipboard operation
ngProgress copied to clipboard

provide destory instance method

Open tiberiu80 opened this issue 10 years ago • 2 comments

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.

tiberiu80 avatar Oct 22 '15 14:10 tiberiu80

+1

psmarcin avatar Jan 18 '16 14:01 psmarcin

@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();
});

cetra3 avatar Feb 09 '16 23:02 cetra3