Bind TextBox, date and dropdownlist value to parameter angularJS wcfRest

538 views Asked by At

I have an angularJS using WCFrest Project

I create dropdownlist and datepicker for parameter to filter showed data. Search Form can be seen on picture below

enter image description here

This is the html code

<!--Date From-->
<div class="col-md-4">
  <input id="txtOldDate" type="date" value="2000-01-01" class="datepicker" />
</div>

<!--Date To-->
<div class="col-md-1">
  <label for="labelTo" class="control-label">To</label>
</div>
<div class="col-md-4">
  <input id="txtNewDate" type="date" class="datepicker" />
  <!-- Set default date value to now-->
  <script>
    document.getElementById('txtNewDate').value = new Date().toISOString().substring(0, 10);
  </script>
</div>

<!--Departement-->
<div class="col-sm-4">
  <div class="dropdown">
    <select class="form-control" ng-model="DdlDeptManager" ng-change="DdlManager(DdlDeptManager)">
      <option ng-repeat="d in GetDeptManager" value="{{d.Department}}">{{d.Department}}</option>
    </select>
  </div>
</div>

<!--Employee-->
<div class="dropdown">
  <!-- @departemen parameter from DdlDeptManager -->
  <select id="ddlManagerApproval" ng-model="DdlManager" class="form-control">
    <option ng-repeat="m in GetManager" value="{{m.UserName}}">{{m.FullName}}</option>
  </select>
</div>

<!--Button Show-->
<div class="col-md-2">
 <input id="btnSubmit" type="button" class="btn btn-primary" ng-click="SearchApproval()" value="Show" />
</div>

This is my control approvalCtrl.js

//Control for search purposes

$scope.SearchApproval = function() {
  var search = {
    //employeeID: $scope.employeeID,
    oldDate: $scope.oldDate,
    newDate: $scope.newDate,
    departemen: $scope.departemen,
    approver: $scope.approver
  }
  var promiseGet = GetApproval.GetApprovalData(search);
  //GetApprovalData();
  promiseGet.then(function(pl) {
      $scope.GetApprovalData = pl.data
    },
    function(errorPl) {
      console.log('Some Error in Getting Records.', errorPl);
    });
}

This is the service.js, for employeeID because the session is not created, i forced add value to it on the uri

this.GetApprovalData = function(employeeID, oldDate, newDate, departemen, approver) {
  return $http.get("http://localhost:51458/ServiceRequest.svc/GetApproval?employeeID=" + "11321" + "&oldDate=" + oldDate + "&newDate=" + newDate + "&departemen=" + departemen + "&approver=" + approver);
};

My Question is, how to make the value on datepicker id = txtOldDate to give a paramater value to oldDate, txtNewDate to newDate, and other dropdownlist to departemen and approver parameter?

Thanks in Advance.

1

There are 1 answers

0
Sharmila On

Hi Randy I have reproduced your code without service sorry for that. Used hardcode array to populate dropdown. Kindly check this url

https://plnkr.co/edit/eSriV68HkhQhzt1yE6DE?p=preview

  $scope.GetDeptManager = [{
Department : 'department1'
 }, {
 Department: 'department2'
}];

$scope.GetManager = [{
FullName : 'manager1'
}, {
FullName: 'manager2'
}]

And you have to assign ng-model values for your input elements so that you will get those values in controller.