1
Every time I select a Bundle, add in an array, example:
Items are some data I picked up, I just passed a few for testing
var items = [755, 20, "E", 274]
$scope.selectBundle = function(){
var info = {
cod: items[3],
bundle: items[0],
espessura: items[1],
classificacao: items[2]
};
// Passa as informações para o cart
$rootScope.selectedBundle.push(info);
// Fecha o modal
$modalInstance.close();
}
Whenever I click to open a new modal, "items" change values and adds in the selected.
What I want and am not getting is if in the next modal I open, check if there is already the Bundle information in the array to leave the select button disabled
Example: http://jsfiddle.net/hqypngej/1/ I did similar to my code to show as example.
Some parts of my JS file are like this at the moment:
app.run(function($rootScope, $http){
$rootScope.cod_mercad = null;
$rootScope.selectedBundle = [];
});
app.controller('mainController', function($scope, $rootScope, $http, $location, $modal){
$scope.open = function (bundle, espessura, classificacao, codigo) {
$scope.items = [bundle, espessura, classificacao, codigo];
// console.log($scope.items);
var modalInstance = $modal.open({
templateUrl: 'rotas/modal', // Endereço da view modal
windowClass: 'full',
size: 'lg',
controller: 'modalController',
resolve: {
items: function () {
return $scope.items;
}
}
});
}
});
// Controller que define todo o modal
app.controller('modalController', function($scope, $http,$modalInstance, $rootScope, items){
// Busca as informações do bundle passando os dados
$http.post('/ajax/bundle', {'items':items}).success(function(data){
$scope.dados = data['dados'];
$scope.nchapas = data['chapas'];
$scope.imagens = data['imagens'];
// Define o tamanho da div que mostra as imagens secundarias
// (Total de imagens + imagem principal) * tamanho de cada bloco somando com margin + padding do conteudo
var width = $scope.imagens.length * 215 + 30;
$('#imagem-secundaria').css('width',width);
});
// Seleção de bundle
$scope.selectBundle = function() {
var info = {
cod: items[3],
bundle: items[0],
espessura: items[1],
classificacao: items[2]
};
// Passa as informações para o cart
$rootScope.selectedBundle.push(info);
// Fecha o modal
$modalInstance.close();
}
});
I’m not familiar with Angular mto, is this what you want? http://jsfiddle.net/hqypngej/
– Sergio
So I try to do it this way, but the repeater always returns true in the application.
– PGz
I updated fiddle, now it has the same error as my system. http://jsfiddle.net/hqypngej/1/
– PGz