Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+2 votes
2 views
in Web Technology by (47.6k points)

In this particular case, what options do I have to make these inputs call a function when I press Enter?

// HTML view // 

<form> 

<input type="text" ng-model="name" <!-- Press ENTER and call myFunc --> /> 

<br /> 

<input type="text" ng-model="email" <!-- Press ENTER and call myFunc --> /> 

</form> 

// Controller // 

.controller('mycontroller', ['$scope',function($scope) { $scope.name = ''; 

$scope.email = ''; 

// Function to be called when pressing ENTER 

$scope.myFunc = function() {

 alert('Submitted'); 

  }; 

}])

1 Answer

+2 votes
by (106k points)
edited by

If you want to make inputs call a function after pressing Enter.

Looking for Angularjs material from basics! Refer to this video on Angularjs provided by Intellipaat:

 then you can use the below-mentioned code:-

<form ng-submit="myFunc()" ng-controller="mycontroller"> 

<input type="text" ng-model="name" />

<br /> 

<input type="text" ng-model="email" /> 

</form>

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...