Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.