Belal Othman Belal Othman - 4 months ago 40
AngularJS Question

submit angularjs form from controller with parameters

I am using this form to do search fucntion

<form id="searchForm" name="searchForm" class="form-inline" ng-submit="ul.callServer(criteria)" novalidate>
<div class="form-group" style="margin-top: 5px;">
<label class="searchFormLabel" for="searchUserName">User Name</label>
<input type= "text" ng-model = "criteria.userName"/>
<label class="searchFormLabel" for="searchUserName">First Name</label>
<input type= "text" ng-model = "criteria.firstName"/>
<label class="searchFormLabel" for="searchUserName">Last Name</label>
<input type= "text" ng-model = "criteria.lastName"/>
</div>


<!---------------------------------------------------users----------------------------------------------------->
<div class="form-group" style="margin-top: 5px;" ng-init="criteria.userType='-1'">
<label class="searchFormLabel" id="searchUser" for="searchUser">
User Type
</label>
<label style="margin-left: 0px">
<input type="radio"
name="userTypeRadioOptions"
id="searchAll"
value="-1"
ng-init="initForm()"
ng-model="criteria.userType"
ng-click="clickAllOrdersButton()">
All
</label>
<br>
<label style="margin-left: 124px">
<input type="radio"
name="periodRadioOptions"
id="searchPending"
value="0"
ng-init="initForm()"
ng-model="criteria.userType">
Back Office
</label>
<br>
<label style="margin-left: 124px">
<input type="radio"
name="periodRadioOptions"
id="searchFinished"
value="1"
ng-init="initForm()"
ng-model="criteria.userType">
Mobiele
</label>
<br>
<label style="margin-left: 124px">
<input type="radio"
name="periodRadioOptions"
id="searchFinished"
value="2"
ng-init="initForm()"
ng-model="criteria.userType">
Klanten
</label>
</div>


when press on button "search" I call the function ul.callServer(criteria)

as you can see I can filter by row type
and this is the scenario I need to implement


  • user search for rows with specific type (done)

  • user edit the row and change the row type (done)

  • I want to refresh the displayed rows with the selected search fields value (not done)



what I want is to call the function ul.callServer(criteria) from controller when I finish the edit operation

if it is not clear please tell me and I will explain more

example:
- I search for rows with type "X" so 3 rows are displayed
- I edit one row and change the type from "X" to "Y"
- when I press on button save to save my new row values I want to
1- update the value of the edited row
2- (Automatically and without the need to press the button search again) display only the rows with type "X"

Answer

I find the solution

$timeout(function(){
  angular.element('#searchForm').triggerHandler('submit');
});
Comments