Suppose, i have a componentA and a componentB
@Component({
selector: 'appA',
templateUrl: './appA.html',
styleUrls: ['./appA.css']
})
export class componentA{
constructor(private route: Router) { }
moveFront() {
this.route.navigateByUrl('componentB');
}
}
@Component({
selector: 'appB',
templateUrl: './appB.html',
styleUrls: ['./appB.css']
})
export class componentB{
constructor(private route: Router) { }
moveBack() {
this.route.navigateByUrl('componentA');
}
}
now when i call the moveFront() function, componentB gets called but i want to pass some data as well to the component, how can i do that?
both my component is a child component, i want to transfer data to and from the one child component to another child component. how can i do it.