akserg / ng2-slim-loading-bar

Angular 2 component shows slim loading bar at the top of the page.
MIT License
358 stars 93 forks source link

Set default values on component #14

Closed andyrue closed 8 years ago

andyrue commented 8 years ago

I'd like to be able to set the color and height on the component selector like this:

<ng2-slim-loading-bar [color]='color' [height]='height'>

color and height being string variables set in my app component constructor. I see @Inputs in the component for those variables so I thought I could do something like that, but it doesn't work. If I set anything like that on the selector nothing loads if I call this.slimLoadingBarService.start(), it only works if I don't try to change the color/height. Anyway to do this without having to call this.slimLoadingBarService.color='blue', etc.?

akserg commented 8 years ago

I have created plunker for you to prove all work as expected.

andyrue commented 8 years ago

Thanks! I see my real problem is I was setting the variable in the constructor....Your example was very helpful though, couldn't figure out how to put the options inline like that. Thanks for your guidance!