Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70612

Detect change to @input variable programmatically - equivalent to watch

$
0
0

@danbucholtz_brady wrote:

Hello,

I have a series of components that talk to eachother through @input and @output events/subscribers. Basically, a child component publishes an event via the @output EventEmitter, and the parent then passes the result back down to a different child via the input directive in the html.

For the sake of discussion, let's say I have this decorated variable in a component:

@input var myVar= "tacos"

I am looking for a way to detect when a variable's value changes in my javascript component code. There is the ngOnChanges function, and I suppose I could inspect the SimpleChange object for a reference to "myVar". Is there a better, more scalable way to do it, similar to $scope.$watch functionality from ng1? I cannot figure this out from extensive googling.

I am a bit of an observable n00b so I am hoping that's the secret sauce I need.

Thanks,
Dan

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70612

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>