I am new to Angular and would like to learn how to accomplish this task I have a dropdown that contains a list of LotType. When a Lot type is selected.I want to make an HTTP GET call to a web API method which returns the list of Lots according to the selected Type
My app.js
app.factory('LotService',['$http',function($http){
var factory={};
factory.getLots=function(selectionType){
$http.get('http://localhost:8080/planification/lots/',{
params:{
"type":selectionType
}
})
.success(function(data){
Lots=data;
})
}
return factory;
}]);
app.controller("ExampleController",['$scope','LotService',function($scope,LotService){
$scope.Types=['particulier','admin','indus'];
$scope.getLots=function(selectionType){
$scope.Lots=LotService.getLots(selectionType);
}
$scope.getLots(selectionType);
}]);
my index.htm
<div class="form-group">
<label class="col-sm-3 control-label">Type client</label>
<div class="col-sm-9">
<select class="selectpicker form-control" multiple ng-model="test.type" ng-change="getLots(test.type)">
<option ng-repeat="type in Types" value="{{type}}">{{type}}</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Lot </label>
<div class="col-sm-9">
<select class="selectpicker form-control" ng-model="test.lot">
<option ng-repeat="lot in Lots" value="{{lot}}">{{lot}}</option>
</select>
</div>
</div>