0

I have an html element (div) I append anther html element like (textarea) to to this (div), I want to bind the value of the added element to ng-model which is an area

.html file

<div id="new-view{{$index}}"></div>

.js file

var parent = $('#new-view' + controllerIndex); 

var question = angular.element('<textarea data-ng-model="self.array['+Index+'].question"></textarea>');

parent.append(question); 

How to I bind what the user will write inside this text area to the array?

Mike Vranckx
  • 5,557
  • 3
  • 25
  • 28
sara
  • 1

1 Answers1

0

You can try another approach with ng-repeat directive. Operate on your data. And angular 2-way binding will update your interface.

Little example: http://jsfiddle.net/joshdmiller/hb7lu/

<div >
    <textarea ng-repeat="q in questions" ng-model="q.text"></textarea>        
</div>
nikita
  • 111
  • 4