2

Am trying to pass selected row value from one component to another on the button click. but in this, example, from where can get selected row values and pass the selected value on button click? followed by that routing will happen

this.selection.selected returns the same object multiple time. how to stop that. i want to pass the value like

    <button (click)='onSelect(row)'>select row </button>

    onSelect(id){
    this.selectedRowValue = id
        //some logics
    }

could someone tell me how to pass the selected row value from one component to another?

1 Answer 1

2

If you add this code in your component, selectedElements object changes with every selection change event

  selectedElements: PeriodicElement[] = [];

  constructor(){
    this.selection.changed.asObservable().subscribe(a => this.selectedElements = [...this.selection.selected]);
  }
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the quick response. but how the selected value? console.log(this.selection.selected) not returning selected row value properly
Forked your example and this.selection.selected returns all selected items
sorry again. actually, am looking for to send the selected value to button click event so that i can do page routing. how to pass the selected to button click. that' s what my issue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.