I have some problems in understanding how to extend correctly a service in angular2, maybe because I don't understand well how to extend a class in typescript.
SuperClass
@Injectable()
export class CallService{
constructor(private errror:string){
this.errMsg=errror;
}
private _errMsg:string;
set errMsg(arg0:string){
this._errMsg=arg0;
}
get errMsg():string{
return this._errMsg;
}
}
SubClass
@Injectable()
export class DownloadService extends CallService{
constructor(private error:string,private http:Http){
super(error)
}
}
App.Component
@Component({
selector:'my-app',
templateUrl:'app/app.component.html',
styleUrls:['app/app.component.css'],
directives:[ROUTER_DIRECTIVES,WaitComponent],
providers:[DownloadService,SwitcherService,CallService,WaitService]
})
export class AppComponent{
title:'App'
constructor(
private areadownloadservice:AreaDownloadService,
private waitService:WaitService,
private switcherservice:SwitcherService,
private callService:CallService){}
)
}
What I want to do is to extend some classes with CallService so that all class that make a calls will have a errMsg string property to set or get, but I get this exception:
No provider for String!
What did I missed?
stringtype annotation in constructor makes the injector to look forstringprovider, and there is none, and there is also no provider defined forerrorin the component.errorparameter?