![](/img/trans.png)
[英]Send a number value from one component to another component in Angular2
[英]In angular2 need to send data from one component to another component
在从登录组件输入手机号以验证otp组件的otp之后,我需要该手机号和用户输入的国家/地区代码作为参数传递给otp服务中的api。 我需要将数据从登录名传递到otp组件,我该如何在angular2中执行该操作?
Sandip是正确的。 例如,在“ SharedDataService”中定义以下共享变量:
import { Injectable } from '@angular/core';
@Injectable()
export class SharedDataService{
hasUserLoggedIn: boolean;
}
然后在“ AppComponent”中使用此服务:
@Component({
providers: [ SharedDataService ]
})
然后可以在整个应用中使用该变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.