Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

angular2 Release injecting from one Constructor to another.

Posted on 2016-11-17
4
Medium Priority
?
81 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 59

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 59

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

618 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