Question about ng-model in ng-repeat loop in angularjs

Source: Internet
Author: User
I am a beginner in angularjs. Now I have encountered such a problem in the project. In angularjs, ng-repeat loops through a form, the ng-model content of the same name is used in multiple forms generated. Changing the content based on angular's two-way data binding will update all content...

I am a beginner in angularjs. Now I have encountered such a problem in the project. In angularjs, ng-repeat loops through a form, the ng-model content of the same name is used in multiple forms. If you change the content of an angular two-way data binding, all content is updated, I want to know if there is any good solution. Thank you for your answers.

Loop code

This is the result after the input.

Reply content:

I am a beginner in angularjs. Now I have encountered such a problem in the project. In angularjs, ng-repeat loops through a form, the ng-model content of the same name is used in multiple forms. If you change the content of an angular two-way data binding, all content is updated, I want to know if there is any good solution. Thank you for your answers.

Loop code

This is the result after the input.

Texeure is under the global scope, and repeat has its own scope, which "inherits" the global scope.
The input model should use the valid variables of scope in repeat.
You can write

{Item. value }:{{ item. price }}

No,ng-repeatGenerates$$hashKeyWill locate each array, so changing one won't update all

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.