ng-value

What is ng-value:ng-value is used to bind value in radio button , select option dynamically..
Description of ng-value:ng-value has priority 0..
Syntax of ng-value:
<element ng-value="expression">

</element>
or


<input ng-value="expression" />
How to Use ng-value/ng-value Example::
 Example 1:
<div ng-app="webapp">
    <div ng-controller="angularjsexampleCtlr" ng-init="value1='Hello';value2='Hi'">
        <div>
            Angularjs Example of ng-value  
            <label><input type="radio" name="rdo" ng-value="value1" />  {{value1}}</label>
            <label><input type="radio" name="rdo" ng-value="value2" />{{value2}}</label>
         
        </div>
    </div>
</div>

Example 2:
<div ng-app="webapp">
    <div ng-controller="angularjsexampleCtlr" >
        <div>
            Angularjs Example of ng-value
            <label><input type="radio" name="rdo" ng-value="value1" />  {{value1}}</label>
            <label><input type="radio" name="rdo" ng-value="value2" />{{value2}}</label>
        </div>
    </div>
</div>

<script>
    angular.module('webapp', []).controller('angularjsexampleCtlr', function ($scope, $http) {

        $scope.value1 = 'Hello';
        $scope.value1 = 'Hi';
       
    });

</script>

No comments :

Post a comment