?
Solved

angular2 Release injecting from one Constructor to another.

Posted on 2016-11-17
4
Medium Priority
?
72 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:Seven price
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 58

Accepted Solution

by:
Julian Hansen earned 2000 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:Seven price
ID: 41892879
Thanks Julian. Give me a couple of days to catch up. Much appreciated.
0
 
LVL 9

Author Closing Comment

by:Seven price
ID: 41899462
Thanks understand now.
0
 
LVL 58

Expert Comment

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

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…
Suggested Courses

770 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