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

mysql - FireDac error 314 - but DLLs are in program directory -

wpf - C# NAudio - Changing audio playback position still plays a small buffer of old position -

Log not being recorded for quickfix c++ Session -