I have a problem with my CRUD operations in the service. When I click on Create Btn it is creating an object but it doesn't push the object in the table list.
Ctrl (where's the table list):
$scope.nameslist = CrudService.getAll();
Ctrl (for Modal dialog):
$scope.createItem = function (newObj) {
CrudService.create(newObj);
$scope.newObj = null;
$scope.ok();
}
CRUD Service (it's a .factory):
...
return {
getAll: function () {
return resService.names.query();
},
create: function (newObj) {
resService.names.save(newObj);
//this.getAll.push(newObj); //this doesn't work
}
...
Request Service (also a .factory):
...
return {
names: $resource(baseUrl + '/api/names/:Id', {
Id: '@Id'
}, {
'update': {
method: 'PUT'
}
})
...
Can anyone help me? How can I push the new object in the table list?