I am new in angular and trying to figure out one issue which is causing me NullInjector error.
I have a nav-bar component which include a search field. The search filed is giving response based on API GET call. I am able to pass the result from nav-bar component to another(home/landing screen) using @input @output annotation.
So in if condition in function I want to call a function(which include another API call) from home component to navbar component. When I am including the component and function in another component , I am getting null injector
error and I am not able to navigating from home component to some other component.
In nav-bar I did :
@Output() public found = new EventEmitter<any>();
constructor(private authService: AuthService, private home: HomeComponent)
{ }
searchapicall(searchValue: string) {
this.authService.setSearchApi(this.value).subscribe(results => {
this.SearchResult = results;
console.log("--------------------->", results);
this.found.emit(results);
});
if (searchValue == '') {
this.home.getOrderList(); <================ this function is in home component.
}
}