Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide destory instance method #96

Open
tiberiu80 opened this issue Oct 22, 2015 · 2 comments
Open

provide destory instance method #96

tiberiu80 opened this issue Oct 22, 2015 · 2 comments

Comments

@tiberiu80
Copy link

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.

@psmarcin
Copy link

+1

@cetra3
Copy link
Collaborator

cetra3 commented Feb 9, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants