angularjs - How to pass dropdown data with other object in Angular js -


i need pass select list data other forms value . there problem when passing there 2 objects how pass values . can solve

angular code

var app = angular.module('projectmdl', []); app.controller('projectcontroller', function ($scope, projectservice) {     $scope.action = 'add';     getcustomer();     loadprojects();     function getcustomer() {         projectservice.getcustomerdetails().then(function (d) {             $scope.customers = d.data;         }, function () {             alert("error loading customer details");         });     }      function loadprojects() {         projectservice.loadproject().then(function (d) {             $scope.prjects = d.data;         }, function () {             alert("error loading project details");         });     }      $scope.saveproject = function () {         var r = confirm("are sure want insert ?")         if (r == true) {             if ($scope.action == 'add') {                 projectservice.addprojectdetails($scope.project).then(function (d) {                     loadprojects();                     $scope.msg = 'insert successfully';                     $scope.cu = null;                     $scope.pr_code = '';                     $scope.pr_name = '';                     $scope.pr_description = '';                 }, function () {                     loadprojects();                 });             }         }         else {              loadprojects();         }     }     $scope.clearproject = function () {         $scope.msg = '';     }  }) .service('projectservice', function ($http) {     this.getcustomerdetails = function () {         var response = $http({             method: 'get',             url: '/admin/customerdetails',             datatype:'json'         });         return response;     }      this.loadproject = function () {          var response = $http({             method: 'get',             url: '/admin/projectdetails',             datatype:'json'         });         return response;     }      this.addprojectdetails = function (projects) {          var response = $http({             method: 'post',             url: '/admin/addprojects',             data: projects,             datatype:'json'          });         return response;     }   }) 

asp mvc code

 [httppost]         public string addprojects(project projects) {             if (projects != null)             {                 te.projects.add(projects);                 te.savechanges();                 return "project add successfully";             }             else {                 return "error";             }          } 

html code

<form class="form-horizontal" method="post" name="basic_validate" id="basic_validate" novalidate="novalidate">                                  <div class="control-group">                                     <label class="control-label">project code</label>                                     <div class="controls">                                         <input type="text" ng-model="project.pr_code" name="required" id="required">                                     </div>                                 </div>                                 <div class="control-group">                                     <label class="control-label">project name</label>                                     <div class="controls">                                         <input type="text" ng-model="project.pr_name" name="name" id="name">                                     </div>                                 </div>                                  <div class="control-group">                                     <label class="control-label">description</label>                                     <div class="controls">                                         <input type="text" ng-model="project.pr_description" name="name" id="name">                                     </div>                                 </div>                                 <div class="control-group">                                     <label class="control-label">customer</label>                                     <div class="controls">                                          <select style="width:210px;">                                                                                      <option ng-repeat="cu in customers" value="{{cu.cus_code}}" ng-selected="true">{{cu.cus_name}}</option>                                         </select>                                      </div>                                 </div>                                  <div class="control-group">                                     <div class="controls">                                         <input type="submit" value="save" ng-click="saveproject()" class="btn btn-success">                                         <input type="submit" value="clear" ng-click="clearproject()" class="btn btn-success" />                                     </div>                                 </div>                                 <div class="control-group">                                     <div class="controls">                                         <p style="color:green">{{msg}}</p>                                     </div>                                  </div>                                 @*<div class="form-actions">                                      </div>*@                             </form> 


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -