0

I am doing $http services, the size of the information that retrieves is variable, in average is between 300 Bytes and 6KBytes.

I don't understand why it is different when I do the request for the first time, than when I do for the second time. When I do an $http.get retrieves the expected data, but then I do another (without refreshing the page), It doesn't retrieve the expected data, it retrieves data, but less than expected.

Edit

Here is the code, The idea is every time the user change the option in the select, bring the new data for the filters, but as I told before, works for the first time, but not when I change the option in the select

On the view I have a select element

<select data-placeholder="Product" class="span4 chzn-select"
    chosen="productsList" ng-model="selectedProduct"
    ng-options="selectedProduct.name for selectedProduct in productssList"
    ng-change="fetchProductFiltersData();">
</select>

On the controller

$scope.fetchProductFiltersData =  function(){
  FiltersServices.selectedProductId($scope.selectedProduct.productId);
  FiltersServices.getHttpProductData(FiltersServices.getSelectedProductId()).then(function(data){
    FiltersServices.filters(data);
    $scope.filter = FiltersServices.getFilters();
  });
}

On the service

this.getHttpProductData = function(productId){
  var promise = FiltersFactory.getSProductData(productId).then(function(data){
    return data;
  });
  return promise;
}

On the Factory

getProductData: function(productId){
  var promise = $http.get('####/Filters.json?id=' + productId).then(function (response){
      return response.data;
  });
  return promise;
}

Thank you

agusgambina
  • 6,229
  • 14
  • 54
  • 94

0 Answers0