Here is my Demo .
i want to bind textbox to selectlist , i mean when i wrote vahid
the value change to vahid in selectlist .
$scope.options2 = [{
name: 'omid',
value: 'something-about-ali'
}, {
name: 'vahid',
value: 'something-about-vahid'
}];
$scope.$watch('parentText.sms', function(v) {
for (var i in $scope.options2) {
var option = $scope.options2[i];
if (option.name === v) {
$scope.selectedName = option;
break;
}
}
});
Now it's Ok, it works perfectly .
The question is : in our application we have like **15 textbox and selectlist**
like this , and i think $watch makes application too heavy .
Is there any trick or possiblity to do this in better way ?
Thanks
I think as mentioned in the other answer
ng-change
is the way to go.You could also improve your function for finding the option with the use of
ngFilter
so you don't have to write a for loop.Please have a look at your updated demo below or in this plunkr.