嘿,我有两个不同的组件,一个是搜索栏组件,一个是主页组件,它们都是我的应用程序组件的子组件。
所以我想在搜索栏组件下获取一些信息,然后设置从中获取值的对象并将其设置为hope-page组件中的值,同时还调用主页内部的函数。
search-bar.component.ts 内部的代码
constructor(
private homePageComponent: HomePageComponent,
){}
this.homePageComponent.searchQuery.latidude = this.lat;
this.homePageComponentt.searchQuery.longitude = this.lon;
this.homePageComponent.fetchWeatherInfo();
这大致是我迄今为止在搜索栏组件中所拥有的内容,我正在尝试使用位于其他组件中的变量和数据。我怎样才能做到这一点,我尝试过执行服务并使用两个组件的父组件,但我无法让它工作?