0

I have the following:

<div class="row" ng-repeat="item in repo.items">
  <div class="col-md-6 segment">
    <div class="display-text animation editable">
      <pre><span class="contenteditable" 
          tabindex="0"
          contenteditable="true"
          ng-model="item.text"></span></pre>
    </div>
  </div>
</div>

The 2-way binding isn't working for ng-model="item.text", but if I use the expression {{item.text}} within the same iteration it works as it should.

Any specific reason I'm missing which is causing this behavior?

2
  • post your full code including controller. Commented Feb 24, 2016 at 7:19
  • ng-model is only used for input tags and not span!! use {{item.text}} Commented Feb 24, 2016 at 7:27

1 Answer 1

2

ng-model used for input tag when you want to use only for view you should use ng-bind.

So you should use ng-bind="item.text" or {{item.text}} instead of ng-model="item.text" in span tag.

<pre>
     <span class="contenteditable" 
          tabindex="0"
          contenteditable="true"
          ng-bind="item.text"></span>
</pre>

or

<pre>
     <span class="contenteditable" 
           tabindex="0"
           contenteditable="true">{{item.text}}</span>
</pre>
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.