Review the image below;
In my class of services it was like this;
pesquisar(): Promise<any> {
return this._http.get('${this.url}/menus' )
.toPromise()
.then(response => {
response.json();
})
}
I just need to know how my method will stay in the component class;
I tried this way but I did not succeed, I need help;
menu = [];
public title: string;
constructor(
private _menuService: MenuAdminService
) {
this.title = 'Lista de Cardápios';
}
ngOnInit() {
this.pesquisar()
}
pesquisar(){
this._menuService.pesquisar()
.then(menu => {
this.menu = menu;
console.log(this.menu);
});
}