Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Example of ng show / ng hide in Angular JS

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 642
    Comment on it

    If you learning the Angular JS and use a parameter from an object as the expression then the ng-hide and ng-show are given the correct true/false but always remember these true/false is not like boolean so always return false: Consider the example below for showing/hiding using return type true/false

    <script src="http://code.angularjs.org/1.2.0-rc.2/angular.js"></script>
    <script type="text/javascript">
        function controller($scope) {
            $scope.data = {
                show: true,
                hide: false
            };
        }
    </script>
    

    and the HTML is :-

    <script src="http://code.angularjs.org/1.2.0-rc.2/angular.js"></script> <script type="text/javascript"> function controller($scope) { $scope.data = { show: true, hide: false }; } </script>
    <div ng-controller="controller">
        <div ng-show="data.show"> If true the show otherwise hide. </div>
        <div ng-hide="!(data.hide)"> If true the show otherwise hide.</div>
    </div>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: