1
I have this function that generates an array, I need to pass to the mvc controller through JSON, but it is not passing, follow how I am doing:
var app = angular.module('myApp', []);
app.controller('myCtrl', function ($scope) {
$scope.total = "00:01";
$scope.Tolerancia = 0;
$scope.items = [];
$scope.totalProposta = function () {
$scope.soma = 1 + $scope.Tolerancia;
$scope.total = "00:" + $scope.soma;
};
$scope.addItem = function (user) {
$scope.items.push({
de: $scope.total,
ate: user.ate,
tipo: user.tipo,
valor: user.valor,
});
$scope.total = ''
$scope.total = user.ate;
user.ate = '';
user.tipo = '';
user.valor = '';
};
$scope.removeItem = function (index) {
$scope.items.splice(index, 1);
}
$scope.gravaItem = function () {
$.ajax({
type: 'GET',
url: '/TaxaPreco/SalvarItens',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
data: JSON.stringify($scope.items),
success: function (result) {
console.log('Data received: ');
console.log(result);
}
})
};
});
I believe the problem lies in this line:
data: JSON.stringify($scope.items),
But in any case, it doesn’t pass the value, as I can proceed ?