This section involves the restructuring of the code written for our app. We'll do so using the following steps:
- Let's begin by updating the module that contains the create and delete functions. We will also add new methods right after the GET method that we implemented previously in the public/javascripts/app.js file. Let's have a look at the following code:
[root@ip-172-31-95-213 node-api]# vi public/javascripts/app.js
------------------------------------------
angular.module('nodeATM', [])
.controller('mainController', function($scope, $http) {
$scope.formData = {};
$scope.atmData = {};
// Get all atms
$http.get('/api/atm-locations')
.success(function(data) {
$scope.atmData = data["data"];
console.log(data["data"]);
})
...