I have a function inside my controller that I want to be able to call from a $scope method so I can reuse my code only within the controller. I use the function to clear some input fields. I would like to call after a user is inserted as well as I would like to assign it to the a "Clear" button click. Calling the function after inserting works just fine but assigning the function to the method isn't.
If I assign the function directly to the $scope.clearUser method it works but then I can't call it after inserting a user.
function clearUser() {
$scope.EmployeeNumber = '';
$scope.isAdmin = false;
};
$scope.clearUser = clearUser();
//also tried $scope.clearUser = this.clearUser();
//$scope.clearUser = function() {
// $scope.EmployeeNumber = '';
// $scope.isAdmin = false;
//};
<button ng-click="clearUser()" class="btn btn-default">
<i class="fa fa-times"></i> Clear
</button>