Solved

angular2 Release injecting from one Constructor to another.

Posted on 2016-11-17
4
44 Views
Last Modified: 2016-11-23
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.
0
Comment
Question by:sevensnake77
  • 2
  • 2
4 Comments
 
LVL 53

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 41892759
Have you read this article on two way binding on components
https://angular-2-training-book.rangle.io/handout/components/app_structure/two_way_data_binding.html


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
http://plnkr.co/edit/nwRNxpoTuk4M60Y5Khq8?p=preview
0
 
LVL 9

Author Comment

by:sevensnake77
ID: 41892879
Thanks Julian. Give me a couple of days to catch up. Much appreciated.
0
 
LVL 9

Author Closing Comment

by:sevensnake77
ID: 41899462
Thanks understand now.
0
 
LVL 53

Expert Comment

by:Julian Hansen
ID: 41899730
You are welcome.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now