angularjs - Update current model value while using bindings -


new angular, hope asking question correctly.

(angular 1.5 , using components)

parent.html:

<names on-refresh-names='$ctrl.reloadnames'></names> 

parent.js

this.reloadnames = function() { ... } 

names.html

<input ng-model="searchnamevalue"> <button ng-click='$ctrl.onrefreshnames()'></button> 

names.js ...

component.bindings = { onrefreshnames: '&' } 

i want make input search string cleared (searchnamevalue = '';) when onrefreshnames executed. executed in parent , searchnamevalue in child.

how can that?

you can combine statements 1 expression:

<button ng-click="$ctrl.onrefreshnames(); searchnamevalue = '';"></button> 

but in case makes sense move them both function in component controller:

<input ng-model="$ctrl.searchnamevalue"> <button ng-click="$ctrl.onrefresh()"></button> 

where in controller

this.onrefresh = function() {   this.onrefreshnames()   this.searchnamevalue = '' } 

in case, note in parent view should

<names on-refresh-names="$ctrl.reloadnames()"></names> 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -