Created
December 10, 2015 16:11
-
-
Save fellipeh/67a34b1fe88c995a5279 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyAppMobile.angular.service('ParametrosService', ['$rootScope', function ($rootScope) { | |
'use strict'; | |
return { | |
parametros: {nome: '', valor: ''}, | |
refresh: function() { $rootScope.$broadcast('refresh_parametros'); } | |
}; | |
}]); | |
*/*/*/*/*/*/ | |
MyAppMobile.angular.controller('CategoriaPageController', ['$rootScope','$scope', '$http', '$window', 'InitService', | |
'CategoriaListService', 'ParametrosService', | |
function ($rootScope, $scope, $http, $window, InitService, CategoriaListService, ParametrosService) { | |
'use strict'; | |
$scope.goURL = function (v_url) { | |
ParametrosService.parametros.nome = 'params'; | |
ParametrosService.parametros.valor = 'cat=' + v_url; | |
ParametrosService.refresh(); | |
console.log('CategoriaPage:'); | |
console.log(ParametrosService.parametros.valor ); | |
$window.location.href = 'filtro.html'; | |
}; | |
$scope.onItemClicked = function (produto) { | |
DataService.produtoClicked(produto); | |
}; | |
InitService.addEventListener('ready', function () { | |
console.log('Carregando lista de categorias...'); | |
$scope.categorias_loaded = false; | |
CategoriaListService.getCategorias().then(function (result) { | |
console.log(result); | |
$scope.categorias = result.data; | |
$scope.categorias_loaded = true; | |
}, function (err) { | |
console.error(err); | |
}); | |
}); | |
}]); | |
*/*/*/*/* | |
MyAppMobile.angular.controller('FiltroPageController', ['$rootScope', '$scope', '$http', '$window', 'InitService', | |
'ParametrosService', 'FiltroService', | |
function ($rootScope, $scope, $http, $window, InitService, ParametrosService, FiltroService) { | |
'use strict'; | |
$scope.$on('refresh_parametros', function(event) { | |
$scope.parametros = ParametrosService.parametros; | |
}); | |
$scope.Titulo = $scope.parametros.nome; | |
console.log('FiltroPageCtrl'); | |
console.log($scope.parametros); | |
$scope.goURL = function (v_url) { | |
$window.location.href = v_url; | |
}; | |
$scope.onItemClicked = function (produto) { | |
FiltroService.produtoClicked(produto); | |
}; | |
InitService.addEventListener('ready', function () { | |
console.log('Carregando os detalhes...'); | |
$scope.detalhes_loaded = false; | |
FiltroService.getDestaques($scope.parametros.valor).then(function (result) { | |
console.log(result); | |
$scope.detalhes = result.data; | |
$scope.detalhes_loaded = true; | |
}, function (err) { | |
console.error(err); | |
}); | |
}); | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment