All:
Im pretty new to Angular2, when I try to build a simple counter service like:
import { Injectable } from "@angular/core";
@Injectable()
export class Counter {
count = 0;
constructor(start = 0){
this.count = start;
// this.reset();
}
reset(start=0){
this.count = start;
}
inc(){
this.count++;
}
dec(){
this.count--;
}
show(){
return this.count;
}
}
What I tried to do in constructor is set a default init parameter start
to default the count to 0, but I get the error like:
(SystemJS) Can't resolve all parameters for Counter: (?).
My question is:
Is this because Angular2 will consider everything in constructor param list as dependency injection, no other type of param allowed set there or there is other reason for this error? And I have to use that reset()
to achieve same purpose?
Is this correct?
Thanks