export class ChartTypeComponent implements OnInit {
constructor(private router: Router, private tService: TypeService) { }
ngOnInit() { }
vc_generate() {
this.tService.template_type$.subscribe((selectedTemplate) => {
console.log(selectedTemplate);
});
}
}
i need to call the service method from functions in the component...
When i call the service inside from the ngOnInit() it works fine,,but not works when used inside the function
is any wrong?
Answer
i solve the problem by changing Subject to BehaviorSubject in Service..so a subject does not hold values, it just passes them through. if you change from Subject to BehaviorSubject, then it would hold the value you sent it
now the value is printed in the console.
No comments:
Post a Comment