I am build an Angular 4 app in which I am trying to use "model" classes like the following:
export interface UserI {
uid?: string;
birthdate: number;
firstname: string;
}
export class User implements UserI {
uid: string;
birthdate: number;
firstname: string;
avatar: string;
numberOfPictures$: Observable<number>;
constructor(obj: any) {
if (!obj.uid)
throw new Error("User Class#constructor - No uid found for user.");
this.uid = obj.uid;
obj.firstname ? this.firstname = obj.firstname : this.firstname = '';
obj.birthdate ? this.birthdate = obj.birthdate : this.birthdate = 0;
obj.avatar ? this.avatar = obj.avatar : this.avatar = 'boy_1';
}
}
I would like to use one of my provider to set the variable numberOfPictures$
How can I inject it? I am used to see Injection the constructor of components but I don't know how to proceed in this particular case.