icanbeacoder
icanbeacoder

Reputation: 1388

Angular js form submit

I am new to Angularjs. Currently i have code like this that submits the form on button click

<form ng-submit="reloadA(resultsPerPage)">
    <select ng-model="resultsPerPage">
    <option value="10">10</option>
    <option value="25">25</option>
    </select>
     <input type="submit" id="submit" value="Submit" />
    </form>

I need that form should be submitted on selecting the option without need of the submit button

Upvotes: 4

Views: 279

Answers (2)

Chandermani
Chandermani

Reputation: 42669

I believe you can use ng-change here

<select ng-model="resultsPerPage" ng-change="reloadA(resultsPerPage)">

Upvotes: 1

pythonian29033
pythonian29033

Reputation: 5207

ok, for this you should have that ng-submit function in the select, like this;

<form>
   <select ng-change="reloadA(resultsPerPage)" ng-model="resultsPerPage">
      <option value="10">10</option>
      <option value="25">25</option>
   </select>
   <input type="submit" id="submit" value="Submit" />
</form>

Upvotes: 2

Related Questions