我需要将数据从一个组件传递到其模块。我需要组件中的数据才能在模块中使用它。我有一个tab1.component.ts,其中有一个tab.module.ts。在tab.module.ts中,我需要配置一个配置,该配置的值将来自tab1.component.ts,如下所示:
tab1.module.ts
export function createConfig(): SignalRConfiguration {
const config = new SignalRConfiguration();
config.hubName = 'ServerHub';
config.qs = { user: 'Lane' };
config.url = ???'; <==== I NEED THE DATA HERE. IT SHOULD COME FROM THE COMPONENT
config.executeEventsInZone = true;
config.executeErrorsInZone = false;
config.executeStatusChangeInZone = true;
return config;
}
@NgModule({
imports: [
IonicModule,
CommonModule,
SignalRModule.forRoot(createConfig),
FormsModule,
RouterModule.forChild([{ path: '', component: Tab1Page }])
],
declarations: [Tab1Page]
})
export class Tab1PageModule {}
tab1.component.ts
onSubmit(form: NgForm){
if(!form.valid) {
return;
}
this.ipAddress = form.value;
console.log(this.ipAddress); <=== I NEED THIS IN THE MODULE ABOVE
this.cs.startConnection();
}