1

I have this loop to show a list of input text

<div ng-repeat="country in countries">
  <input ng-blur="saveCountryName(country)" type="text" value="{{country.name}}">
</div>

in my controller

$scope.saveCountryName = (country) => {
  console.log(country);
}

country is filled with the original value, how can I get the modified value?

1
  • 1
    Instead of value="{{country.name}}" try using ng-model="{{country.name}}" Commented Oct 20, 2022 at 10:36

1 Answer 1

1

In AngularJS you have all power of two-way data binding, no need to use a special function (saveCountryName).

<div ng-repeat="country in countries">
  <input type="text" ng-model="country.name" ng-model-options="{ updateOn: 'blur'}" />
</div>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.