AngularJS ng-value Directive Last Updated : 24 Aug, 2022 Comments Improve Suggest changes Like Article Like Report The ng-value Directive in AngularJS is used to specify the value of an input element. This directive can be used to achieve the one-way binding for the given expression to an input element, especially when the ng-model directive is not used for that specific element. It is supported by <input> and <select> elements. Syntax: <element ng-value="expression"> Content ... </element> Parameter value: expression: It specifies the value that is bound with the element's value attribute & value property. It is of string type.Example 1: This example describes the basic usage of the ng-value Directive in AngularJS. HTML <!DOCTYPE html> <html> <head> <script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"> </script> <style> body { text-align: center; font-family: 'Times New Roman', Times, serif; } h1 { color: green; } </style> </head> <body ng-app="gfg" ng-controller="geek"> <h1>GeeksforGeeks</h1> <h3>ng-value Directive</h3> <input ng-value="displayVal"> <script> var app = angular.module('gfg', []); app.controller('geek', function ($scope) { $scope.displayVal = "GeeksforGeeks"; }); </script> </body> </html> Output: Example 2: This example describes the ng-value directive in AngularJS, where a value is selected from the list & correspondingly, rendering that value. HTML <!DOCTYPE html> <html> <head> <title>ng-value Directive</title> <script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"> </script> </head> <body ng-app="app" style="padding:20px"> <h1 style="color:green;">GeeksforGeeks</h1> <h2>ng-value Directive</h2> <p>Choose one:</p> <div ng-controller="geek"> <div ng-repeat="l in sort"> <input type="radio" ng-model="my.fav" ng-value="l" name="Sort"> {{l}} </div> <pre>Selected choice is: {{my.fav}}</pre> </div> <script> var app = angular.module("app", []); app.controller('geek', ['$scope', function ($scope) { $scope.sort = [ 'Merge Sort', 'Quick Sort', 'Bubble Sort' ]; $scope.my = { fav: 'Merge Sort' }; }]); </script> </body> </html> Output: Comment More infoAdvertise with us Next Article AngularJS ng-value Directive V Vishal Chaudhary 2 Follow Improve Article Tags : Web Technologies AngularJS AngularJS-Directives Similar Reads AngularJS ng-style Directive The ng-style Directive in AngularJS is used to apply custom CSS styles on an HTML element. The expression inside the ng-style directive must be an object. It is supported by all the HTML elements. Syntax: <element ng-style="expression"> Content ... </element>Parameter: expression: It rep 2 min read AngularJS ng-paste Directive The ng-paste Directive in AngularJS is used to specify custom behavior functions when the text in input fields is pasted into an HTML element. It can be used to call a function that will be triggered when the text is pasted into the input field. It is supported by <input>, <select> and 2 min read AngularJS ng-pattern Directive The ng-pattern Directive in AngularJS is used to add up pattern (regex pattern) validator to ng-Model on an input HTML element. It is used to set the pattern validation error key if input field data does not match a RegExp that is found by evaluating the Angular expression specified in the ng-patter 2 min read AngularJS | ng-selected Directive The ng-selected Directive in AngularJS is used to specify the selected attribute of an HTML element. It can be used to select the default value specified on an HTML element. If the expression inside the ng-selected directive returns true then the selected option value will be displayed otherwise not 1 min read AngularJS ng-readonly Directive The ng-readonly Directive in AngularJS is used to specify the readonly attribute of an HTML element. The HTML element will be readonly only if the expression inside the ng-readonly directive returns true. The ng-readonly directive is required to change the value between true and false. In case, if t 2 min read Like