Solved

angular2 Release injecting from one Constructor to another.

Posted on 2016-11-17
4
62 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
[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 57

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 57

Expert Comment

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

737 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