1. user.service.ts
private jumpTimeSlotSource = new Subject<string>();
public jumpTimeSlot$ = this.jumpTimeSlotSource.asObservable();
public onJumpTimeSlot(timeId: any) {
const self = this;
self.jumpTimeSlotSource.next(timeId);
}
2. user.component.ts
public onClickRoute(timeId: any) {
const self = this;
self.userService.onJumpTimeSlot(timeId)
}
3. user.component.html
private jumpTimeSlotSource = new Subject<string>();
public jumpTimeSlot$ = this.jumpTimeSlotSource.asObservable();
public onJumpTimeSlot(timeId: any) {
const self = this;
self.jumpTimeSlotSource.next(timeId);
}
2. user.component.ts
public onClickRoute(timeId: any) {
const self = this;
self.userService.onJumpTimeSlot(timeId)
}
3. user.component.html
<button (click) ="onClickRoute('100001')">Route</button>;
4. user-edit.component.ts
public subscription: Subscription;
constructor(private userService: UserService, private _router: Router) {
const self = this;
self.subscription = self.userService.jumpTimeSlot$.subscribe((res) => {
self._goToAnchor1(res);
});
}
private _goToAnchor1(timeId: any) {
const self = this;
self._router.navigate(['/user', 'activity'], { fragment: timeId });
}
ngOnDestroy() {
this.observer.disconnect();
this.subscription.unsubscribe();
}
public subscription: Subscription;
constructor(private userService: UserService, private _router: Router) {
const self = this;
self.subscription = self.userService.jumpTimeSlot$.subscribe((res) => {
self._goToAnchor1(res);
});
}
private _goToAnchor1(timeId: any) {
const self = this;
self._router.navigate(['/user', 'activity'], { fragment: timeId });
}
ngOnDestroy() {
this.observer.disconnect();
this.subscription.unsubscribe();
}
0 comments:
Post a Comment