मैं उपयोगकर्ता को उपयोग करके ngRepeat
और आइटम की सूची को संपादित करने की अनुमति देने की कोशिश कर रहा हूं ngModel
। ( इस फिडेल को देखें ।) हालांकि, दोनों दृष्टिकोणों से मैंने विचित्र व्यवहार का नेतृत्व करने की कोशिश की है: एक मॉडल को अपडेट नहीं करता है, और दूसरा प्रत्येक कीडाउन पर फॉर्म को ब्लर करता है।
क्या मुझसे यहां कुछ गलत हो रहा है? क्या यह एक समर्थित उपयोग मामला नहीं है?
यहाँ फिडल से कोड है, सुविधा के लिए कॉपी किया गया:
<html ng-app>
<head>
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/css/bootstrap-combined.min.css" rel="stylesheet">
</head>
<body ng-init="names = ['Sam', 'Harry', 'Sally']">
<h1>Fun with Fields and ngModel</h1>
<p>names: {{names}}</p>
<h3>Binding to each element directly:</h3>
<div ng-repeat="name in names">
Value: {{name}}
<input ng-model="name">
</div>
<p class="muted">The binding does not appear to be working: the value in the model is not changed.</p>
<h3>Indexing into the array:</h3>
<div ng-repeat="name in names">
Value: {{names[$index]}}
<input ng-model="names[$index]">
</div>
<p class="muted">Type one character, and the input field loses focus. However, the binding appears to be working correctly.</p>
</body>
</html>