After entering mobile no from login component to verify the otp from otp component i need that mobile no and country code that user entered to pass as parameters to api in otp service. I need to pass data from login to otp component how could i perform that in angular2 ?
Sandip is right. For example define the following shared variable inside the 'SharedDataService':
import { Injectable } from '@angular/core';
@Injectable()
export class SharedDataService{
hasUserLoggedIn: boolean;
}
Then use this service inside say 'AppComponent':
@Component({
providers: [ SharedDataService ]
})
the variable then can be used across the whole app.
Option 1 : You can use Shared Services
Option 2 : Use Pub-Sub way , so that can be used anywhere without injecting a service instance
Option 3 (Which I strongly suggest to use ): Use Redux
Which will help to maintain the app state .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.