Gender : I want to place data coming from my API in the text field so that it can be ch" />

Angular data binding issues ng-value does'nt seems to work

angularjs

108 просмотра

2 ответа

 <label class="item item-input">
    <span class="input-label"> Gender : </span>
   <input type="text" value="{{results.address}}" ng-model="formData.address">
 </label>

I want to place data coming from my API in the text field so that it can be changed later and I am using ng-model to bind the input data to the form so that it can be sent to API for making a change.

But I am getting an empty text field in a text box. value doesn't seem to be working and I have checked changing value to ng-value

When i used this code below everything is working pretty fine ! this means i have no problem in my controller ! i am getting a correct address from my API.

 <label class="item item-input">
    <span class="input-label"> Gender : </span>
   <input type="text"  ng-model="formData.address">"{{results.address}}"
 </label>

While using ng-value i am getting error !

 <label class="item item-input">
                    <span class="input-label"> Gender : </span>
                    <input type="text" ng-value="{{results.address}}" ng-model="formData.address">
                </label>
Автор: Kartik Khandelwal Источник Размещён: 08.11.2019 11:00

Ответы (2)


0 плюса

No need of value attribute when assigning value dynamically. If i understood your question correctly

<input type="text" ng-model="apiValue">

http://plnkr.co/edit/sC0BmKQE1i08bTZlwCVQ?p=preview

Автор: lch Размещён: 20.08.2016 07:34

0 плюса

Please check angular doc ng-value used to achieve one-way binding of a given expression to an input element such as an input[text] or a textarea, when that element does not use ngModel. you can see plnkr

Автор: Abdelrahman M. Allam Размещён: 20.08.2016 07:56
Вопросы из категории :
32x32