I try to focus on the text box when I click on the div a button.
<input type="text" ng-model="myText" id = "area1" ></input>
And my buttons are dynamically generated by the template in the as directive,
<my-buttons > </my-buttons>
app.directive('myButtons', function () {
return {
restrict: "E",
templateUrl: "templates/buttons.html"
link: function ($scope) {}
};
});
Template
<div>
<div>
<div ng-click="submitResult();">
<div ng-style="color:red"> <span>OK</span>
</div>
</div>
</div>
</div>
when I click the send button, it removes the focus from the input, but I want the focus to remain at the input where it was. I know that we can set the focus on
document.getElementById("id").focus();
Do I need to add an attribute to the myButtons directive and pass an input identifier or is there any other workaround in angularjs. A page can have many of these inputs and buttons.
source
share