1

Here i have two dropdown list when i select both the dropdown & click on button that values should Bind the values. Html

<div ng-controller="AdminCntrl">
    <input type="button" ng-click="BtnBindDrp()" class="btn btn-primary" value="Bind">    
    <select class="form-control" ng-model="Date">
     <option value="-1">Select Date</option> <option value="1">1</option> <option value="2">2</option>
</select>
    <select class="form-control" ng-model="Year">
        <option value="-1">Select Year</option> <option value="2001">2001</option> <option value="2002">2002</option>
      </select>
</div>

Controller.Js

  $scope.BtnBindDrp = function () {
          var sss = {
            Date: $scope.Date,
            Year: $scope.Year}
        var seri = AdminServices.GetBindvales(sss);
         }

Service.Js

   this.GetBindvales = function (sss) {
        var ss = $http({
            url: '/Department/Date',
            method: 'Get',
            data: JSON.stringify(sss),
            content: { 'content-type': 'application/Json' }
        })
        return ss;
    }

MvcController

 public JsonResult Date(int Date, int Year)
        {
            return new JsonResult { };
        }

1 Answer 1

1

In service you used JSON.stringify for sss object element. sss is already an object. Don't need to request your server like a string value. And In html to controller data bind perfectly happening from this demo please see at in console for the result. I think at service to Mvccontroller data binding It's not the perfect way you try. Please describe details where is the problem for your data binding issue.

this.GetBindvales = function (sss) {
        var ss = $http({
            url: '/Department/Date',
            method: 'Get',
            data: JSON.stringify(sss),
            content: { 'content-type': 'application/Json' }
        })
        return ss;
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.