One of the ng-models gives null value. When I click the button with the 
function setNewRecord the parameter selectedDocument is null. The first two 
parameters are correct. The javascript code is added as well.


<form name="myForm" >
    <div>
        <select ng-model="selectedCompany">
            <option value="">-- Select Company --</option>
            <option data-ng-repeat="currentSetting in currentSettings" 
value={{currentSetting.SCACCode}}>{{currentSetting.SCACCode}}</option>
        </select>
    </div>
    <div><input id="Text1" type="text"  ng-model="enteredCustomer"/></div>
    <div>
       <select ng-model="selectedDocument" 
ng-click="getTypes(selectedCompany, enteredCustomer)">
           <option value="">-- Select Doc type --</option>
           <option data-ng-repeat="docSetting in docSettings" 
value="{{docSetting.Doc_Type}}">{{docSetting.Doc_Type}}</option>
       </select>
    </div>
    <input id ="btnAdd" type="button" value="Add new record" 
ng-click="setNewRecord(selectedCompany, enteredCustomer,selectedDocument)"/>
</form>

myApp.service('getDocTypesService', ['$http', '$q', function ($http, $q) {
        var allSettings = null;
        this.getDocTypes = function (compName, custName) {
            var def = $q.defer()
            if (allSettings) {
                def.resolve(allSettings);
            } else {
                $http.post('GetDocTypes', { companyName: compName, 
customerName: custName })
                  .then(function (response) {
                      var response = $.parseJSON(response.data)
                      allSettings = response;
                      def.resolve(allSettings);
                  });
            }
            return def.promise;
        }
        }]);
        
        
        
         myApp.controller('myController', ['$scope', 'getDocTypesService',
         function ($scope, getDocTypesService) {
         $scope.getTypes = function(comp, cust) {
         getDocTypesService.getDocTypes(comp, cust).then(function (value) {
         $scope.docSettings = value
            });
         };

         }
         ]);

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to