You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.1 KiB
46 lines
1.1 KiB
const app = angular.module('MyApp', []);
|
|
app.controller('PeopleController', ['$http', function($http){
|
|
this.index = function(){
|
|
$http({
|
|
url:'/people',
|
|
method:'GET'
|
|
}).then((response)=>{
|
|
this.people = response.data;
|
|
});
|
|
}
|
|
this.create = function(){
|
|
$http({
|
|
url:'/people',
|
|
method:'POST',
|
|
data: {
|
|
name:this.newPersonName,
|
|
age:this.newPersonAge
|
|
}
|
|
}).then((response)=>{
|
|
this.index();
|
|
});
|
|
}
|
|
this.edit = function(id){
|
|
$http({
|
|
url:'/people/'+id,
|
|
method:'PUT',
|
|
data: {
|
|
name:this.editedPersonName,
|
|
age:this.editedPersonAge
|
|
}
|
|
}).then((response)=>{
|
|
this.index();
|
|
});
|
|
}
|
|
this.delete = function(id){
|
|
$http({
|
|
url:'/people/'+id,
|
|
method:'DELETE'
|
|
}).then((response)=>{
|
|
this.index();
|
|
});
|
|
|
|
}
|
|
this.index();
|
|
}])
|