Solved

angular2 Release injecting from one Constructor to another.

Posted on 2016-11-17
4
26 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 51

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 51

Expert Comment

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

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

757 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

22 Experts available now in Live!

Get 1:1 Help Now