search

Home  >  Q&A  >  body text

angular.js - ng-bind does not display data, but ng-model can?

The code is as follows

<input type='text' ng-model='cdkey.name'>   {{cdkey.name}}

The input box of ngModel displays the data correctly, but the data is not displayed in the double brackets on the right. What is the reason for this?

Additional: ng-bind can also be displayed correctly, but double curly braces cannot. Is the rendering method of ngBind and double curly braces different? ? ?

为情所困为情所困2831 days ago597

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-05-15 16:55:49

    1. If input里面的ng-model绑定的数据模型不是一个Object, then this should not happen.
    2.ng-bind{{}}The results of rendering data are different when the data model to which they are bound is an object.
    3. I wrote a demo, you can have a look.

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-15 16:55:49

    <input type='text' ng-model='cdkey.name' value="cdkey.name">
    

    The value of the input tag should of course be placed in the attribute valuel.

    reply
    0
  • Cancelreply