Created
August 18, 2016 11:56
-
-
Save nanlabsweb/d2f9c7d1919b0672f91cd82b0605a088 to your computer and use it in GitHub Desktop.
POST - Angular controller example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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