Currently, I am in the process of creating a form to update a row within a database table using REST and AngularJS. However, I am encountering an issue where I am unable to access the data due to a $scope.l undefined error appearing on the web console. I am interested in finding out how I can resolve this problem and successfully configure the form to utilize the REST server for updating the existing content.
//Controller designed for editing a specific item
countryApp.controller('EditLocation', function($scope, $http, $routeParams, $location) {
//
var id = $routeParams.locid;
$scope.activePath = null;
$http.get('http://localhost/slimtest2/location/' + id).success(function(data) {
$scope.location = data;
});
$scope.editrel = function() {
var emP = {
location_id : id,
location_title : $scope.l.location_title,
location_latitude : $scope.l.location_latitude,
location_longitude : $scope.l.location_longitude
}
//Convert data to JSON string
var lucy = JSON.stringify(emP);
alert(lucy);
$http.put('http://localhost/slimtest2/location/1/edit', lucy);
}
});