I am new to angularjs.
When I click on "Click Me" the toggle
method is called. The value of test
changes from false to true, but ng-hide
is not acknowledging the new value of test
.
<div ng-app="myApp" ng-controller="myCtrl">
<table>
<tr>
<td><span ng-hide="{{test}}">Testing</**strong text**td>
<td><span>hello</span></td>
</tr>
<tr>
<td style="cursor:pointer"><span ng-click="toggle()">Click Me</td>
<td><span>hello</span></td>
</tr>
</table>
</div>
script.js
var appX = angular.module('myApp', []);
appX.controller('myCtrl', function($scope){
$scope.test = false;
$scope.toggle = function(){
$scope.test = true;
console.log("toggle is working");
};
});
The ngHide directive shows or hides the given HTML element based on the expression provided to the ngHide attribute.
Since it accepts expression so no need of curly braces!
Change:
to
You need to use curly braces if the directive was expecting
string
instead ofexpression
as an attribute value.Fore more info refer Angular Docs.