I'm trying to pass string argument from component to a service constructor. In case of static value it was easy:
@Component({
selector: 'app-board',
templateUrl: './board.component.html',
styleUrls: ['./board.component.css'],
providers: [UsersDetailProviderService,
{provide: 'boardId', useValue: 'whatever'} ]
})
and at my service:
constructor(private afs: AngularFirestore,
@Inject('boardId') @Optional() public boardId?: string) {
console.log(boardId);
}
and I got my 'whatever' in the console. But what I really wanted to pass, is the real board id. In the component, I'm using activatedRoute to get board id to a local variable.
this.boardId = this.activatedRoute.snapshot.paramMap.get('id');
How can I pass this id to a service?
@edit I could achieve my goal by calling service method that takes board id as argument, and then initialize service data. But I don't think it's a good way to this?