1
Good afternoon ! I’m not being able to create the functionality of editing and removing an object from an angular array, could someone help me ? follows below the code of the controller and the service :
angular.module("appOS").controller("CadastroServicoCtrl",function($scope, Servicos,$location,$timeout){
$scope.servicos = Servicos.listar();
$scope.adicionarServico = function(servico){
$scope.exibirMsg = false;
var id = $scope.servicos.length;
servico.codigo = (id + 1);
Servicos.adicionar(angular.copy(servico));
delete $scope.servico;
$scope.servicoForm.$setPristine();
$timeout(function(){
$scope.exibirMsg = true;
$scope.mensagem = "Serviço Cadastrado com Sucesso!";
}, 2000);
};
});
angular.module("appOS").factory("Servicos", function(){
var servicos = [];
return {
listar: function(){
return servicos;
},
adicionar: function(servico){
servicos.push(angular.copy(servico));
delete servico;
},
remover:function(id){
}
}
});
Any of the answers helpful? Don’t forget to choose one and mark it so you can!
– Sorack