arjun hegde arjun hegde - 1 year ago 68
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?

Answer Source

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


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download