here is my controller script, just a simple get. This just loads data in a table
var app = angular.module('myApp', []);
app.controller('inventariosCtrl', function ($scope, $http) {
$scope.showLoader = true;
$http.get("api/inventarios").then(function (response) {
$scope.showLoader = false;
$scope.inventarios = response.data;
})
})
and here is jquery ajax post to send a form data that adds a row to the table
$("#btnAdd").click(function () {
debugger
var Inventario = {
"Colaborador": $("#Colaborador").val(),
"Armazem": $("#Armazem").val(),
"Total": $("#Total").val(),
"Data": $("#Data").val(),
};
var Localizacoes = [{
"Referencia": $("#Referencia").val(),
"EtiquetasPorInventariar": $("#EtiquetasPorInventariar").val(),
"EtiquetasInventariadas": $("#EtiquetasInventariadas").val(),
"IsValid": $("#IsValid").val(),
"Precisao": $("#Precisao").val()
}]
Inventario.Localizacoes = Localizacoes;
$.ajax({
type: "POST",
url: 'api/inventarios',
data: JSON.stringify(Inventario),
contentType: "application/json;charset=utf-8",
success: function (data, status, xhr) {
alert("The result is : " + status + ": " + data);
},
error: function (xhr) {
alert(xhr.responseText);
}
});
});
I know i could use angular for post too but i will change that later since i'm just learning to use angular. My question is, how can I call the angular http.get after the ajax call is done with jquery so table is refreshed after submit? I tried this but didn't work
<button id="btnAdd" type="button" ng-click="inventariosCtrl">
Submit data
</button>