javascript - How to call function in AngularJS controller with $scope method? -


i have function inside controller want able call $scope method can reuse code within controller. use function clear input fields. call after user inserted assign "clear" button click. calling function after inserting works fine assigning function method isn't.

if assign function directly $scope.clearuser method works can't call after inserting 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> 

omit () pass function:

$scope.clearuser = clearuser; 

or, create @ once:

var clearuser = $scope.clearuser = function() {  } 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -