I load the products in this controller ...
.controller('productosCtrl', function($scope, $http, $q, $location, $ionicLoading, Productos) {
Productos.productos().then(function(argument, $timeout) {
console.log(argument)
$scope.tiendaD = {
nameS: argument.store.name,
addressS: argument.store.address,
idS: argument.store.id,
logoS: argument.store.logo.logo.url
};
$scope.producto = []
for (var i = 0; i <= argument.store.products.length - 1; i++) {
$scope.producto.push({
id: argument.store.products[i].id,
name: argument.store.products[i].name,
description: argument.store.products[i].description,
category: argument.store.products[i].category,
store: argument.store.products[i].store,
price: argument.store.products[i].price,
picture: argument.store.products[i].picture.picture.url
});
}
$scope.$broadcast('scroll.refreshComplete');
})
})
My factory
.factory('Productos', function($q, $http, $location) {
var Api = {};
$http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
Api.productos = function() {
var defer = $q.defer();
var paramId = $location.search().id;
var urlaux = "http://abbie-core.herokuapp.com/api/stores/" + paramId + "?token=" + localStorage.getItem('token') + "&user_id=" + localStorage.getItem('user_id');
$http({
method: 'GET',
url: urlaux,
}).success(function(data) {
defer.resolve(data);
})
return defer.promise;
}
return Api;
})
... and I print them in the view with a ng repeat , where I print these products I put cache view true
, but if I add a new product and leave, and enter the view, I can not see the other product I have to reload the view.
What can I do to break that cache when there is a new product?