Skip to content

Instantly share code, notes, and snippets.

@nanlabsweb
Created August 18, 2016 11:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanlabsweb/d2f9c7d1919b0672f91cd82b0605a088 to your computer and use it in GitHub Desktop.
Save nanlabsweb/d2f9c7d1919b0672f91cd82b0605a088 to your computer and use it in GitHub Desktop.
POST - Angular controller example.
function ContactCtrl($scope, ContactService) {
$scope.firstName = '';
$scope.lastName = '';
$scope.getFullName = function() {
if ($scope.firstName !== '' && $scope.lastName !== '') {
return $scope.firstName + ', ' + $scope.lastName;
} else if ($scope.firstName !== '') {
return $scope.firstName;
} else if ($scope.lastName !== '') {
return $scope.lastName;
} else {
return '';
}
};
$scope.save = function() {
ContactService.save({
firstName: $scope.firstName,
lastName: $scope.lastName
});
$scope.reset();
};
$scope.reset = function() {
$scope.firstName = '';
$scope.lastName = '';
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment