VOOZH about

URL: https://www.geeksforgeeks.org/angular-js/how-to-set-the-input-field-value-dynamically-in-angularjs/

⇱ How to set the input field value dynamically in AngularJS ? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to set the input field value dynamically in AngularJS ?

Last Updated : 30 Jul, 2024

Given an input field and the task is to set the input field value dynamically with the help of AngularJS.

Approach: 

  • A value is being set to the input field despite the user enter something or not. 
  • ng-click event is used to call a function that sets the value to 'This is GeeksForGeeks' with the help of ng-model.

Example 1: In this example, the input field is read-only So the user can not modify it and the value is set dynamically.

Output:

Example 2: In this example, user can modify the input field but the value entered by user can be set dynamically.

Output:

Comment
Article Tags:

Explore