arjun hegde arjun hegde - 4 months ago 6x
AngularJS Question

send textbox input on ng-click

I have an input and a button

<input type="text" name="search_tags" id="search_tags" placeholder="Search by Tags" class="form-control" >
<button type="submit" class="btn btn-primary btn-lg" ng-click="searchTags()">Search</button>

How do I pass the text present in the input textbox to the searchTags() function after button ng-click?


Set ngModel directive with the input control, then pass that to ngClick of button.

<input type="text" ng-model="myText">
<button type="submit"  ng-click="searchTags(myText)">Search</button>

The property myText will be accessible in $scope