I have a method where I get an array. I'm trying to scan this array and compare it to a value of a variable.
cnaeService.cnaes().then(function (result) {
$scope.cnaes = result.data;
vm.cnae = $scope.cnaes;
var res = listCnae(vm.cnae);
console.log(res);
}, function (error) {
if (error.status == 404) {
$scope.error = 'Nenhum parametro foi encontrado.';
}
else {
$scope.error = error.statusText;
}
});
function listCnae(cnae) {
for (var i = 0; i < $scope.cnaes; i++) {
if (contribuinte.cnaes === $scope.cnaes.codigo) {
$scope.descricao = contribuinte.descricao[i];
}
}
}
But it does not return anything to me.