• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 91
  • Last Modified:

angular2 Release injecting from one Constructor to another.

table list
(click)="onupdate(ID, $index)

export class ListComponents
 public myformdata: number;
  onupdate(ID: number) {
       console.log('loading ID', JSON.stringify(ID));
       this.myformdata = (ID);
       return this.myformdata;

Table Edit
Once I click this event I see the ID in my console.

I want to retrive it in another component.
export class ListEditComponents {
constructor(public _dashlit: ListComponents) {

  ngOnChanges(): void {


Open in new window

I tried ngOnchanges. but not sure how to detect the changes.
Seven price
Seven price
  • 2
  • 2
1 Solution
Julian HansenCommented:
Have you read this article on two way binding on components

What you need to do is define your ID using the ngModel directive - and pass it into each of the components that need to see that value.

When you change it in the first it will updated in the second

This plunker has a working sample
Seven priceFull StackAuthor Commented:
Thanks Julian. Give me a couple of days to catch up. Much appreciated.
Seven priceFull StackAuthor Commented:
Thanks understand now.
Julian HansenCommented:
You are welcome.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now