I have some problems understanding how to properly distribute the service in angular2, maybe because I don’t understand how to extend the 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 extend some classes with CallService so that the whole class making the calls has an errMsg string property for setting or receiving, but I get this exception:
There is no provider for String!
What did I miss?
source
share