0

i have a question on how to get variables set in my controller in a html tag?

Example:

<table class="table table-striped table-bordered table-hover" ng-hide="checked">

The ng-hide should be a variable. In my controller i have:

$scope.checked = "checked";

How to use the variable in the above example?

<table class="table table-striped table-bordered table-hover" ng-hide="{{ checked }}">

Doesnt work.

1
  • ng-hide="checked == 'checked'" Commented Jun 15, 2014 at 13:22

2 Answers 2

1

ng-hide ng-show ng-desabled all of them rely on a true/false variable,

So you have to consider a $scope.checked=false or true in your controller , and that will work

Sign up to request clarification or add additional context in comments.

Comments

0

I can give you this.

 <!DOCTYPE html>
    <html ng-app>
    <head>
        <title></title>
        <script type="text/javascript" src="angular.min.js"></script>
        <script type="text/javascript">
        function testCtrl ($scope) {
            $scope.checked = true;

            $scope.changeHide = function(){
                $scope.checked = false;
            }
        }
        </script>
    </head>
    <body ng-controller="testCtrl">
        <div ng-show="checked">
            Must be shown on start.
        </div>
        <button ng-click="changeHide()">Hide</button>
    </body>
    </html>

ng-show or ng-hide , it does not matter.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.