Sunday, 22 November 2015

ng-disabled

What is ng-disabled:ng-disabled is used to make element (input ,select ,textarea,button etc) disabled..
Description of ng-disabled:ng-disabled has priority 100. When given condition in ng-disabled is true ,targeted element become disabled .Otherwise when condition is false targeted element has no effect..
Syntax of ng-disabled:
<element ng-disabled="expression">

</element>
or


<input ng-disabled="expression" />
How to Use ng-disabled/ng-disabled Example::
 Example 1:
<div ng-app="webapp">
    <div ng-controller="angularjsexampleCtlr" ng-init="flag=true">
        <div>
            Angularjs Example of ng-disabled
            <input type="text" ng-disabled="flag" />

        </div>
    </div>
</div>

Example 2:
<div ng-app="webapp">
    <div ng-controller="angularjsexampleCtlr">
        <div>
            Angularjs Example of ng-disabled
            <input type="text" ng-disabled="flag" />
            <input type="button" ng-click="myfun()" />
        </div>
    </div>
</div>

<script>
    angular.module('webapp', []).controller('angularjsexampleCtlr', function ($scope, $http) {
        $scope.myfun = function () {
            if ($scope.flag == false || $scope.flag == undefined)
                $scope.flag = true;
            else
                $scope.flag = false;
        }
    });

</script>

No comments :

Post a Comment