Is there any way the ng-model value of an input text box can be set using setAttribute method or in any other way. I have a button that adds textbox by cloning text type inputs in html. But I cannot figure out how to set the ng-model as the textboxes are created, rather cloned from the onclick method of the button. PS: the value for ng-model is different for different textboxes as they are created.
Update
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script>
var add = function() {
var txtClone = document.getElementById("textinput").cloneNode(true);
txtClone.setAttribute("ng-model", "name");
document.getElementById("target").appendChild(txtClone);
}
</script>
<body>
<input type="text" id="textinput" placeholder="Enter name here">
<div ng-app="">
<p>Input something in the input box:</p>
<p id="target">Name : <hr></p><button click="add()">Type</button>
<h1>Hello {{name}}</h1>
</div>
</body>
</html>
Here I cloned the input text outside the div with ng-app when the button(Type) is clicked,
there I tried set the ng-model value of the cloned textbox with setAttribute.... but it does not bind. My question is that is there any way I can set this ng-model value from the js script?