Saturday, 16 January 2016

How to bind a ng-model with input type, Get and Set value from/to input type

Use of ng-model:ng-model is used with input to get and set value.
<div ng-controller="angularjsexampleCtlr" class="col-lg-12">
        <div class="col-lg-6">
            Get and Set Value form/in input
        </div>
        <div class="col-lg-6">
            <input type="text" ng-model="value"><input>
            <button ng-click="myfun()">Show Value</button>
        </div>
    </div>

o/p:     selectedValue= {{value}}

<script>
    angular.module('webapp', []).controller('angularjsexampleCtlr', function ($scope, $http) {
        $scope.myfun=function()
        {
            alert("Value : "+$scope.value);
        }
    });

</script>
Get and Set Value form/in input
o/p: value = {{value}}

No comments :

Post a Comment