HappyCoding HappyCoding - 2 years ago 70
AngularJS Question

Change ng-hide value when clicking button

I'm making a small example to change the value of

after clicking button, but it didn't work.

I've tried:

angular.module('myModule', []).controller('myController', function ($scope) {
$scope.hide= false
$scope.change = function () {
$scope.hide = !$scope.hide

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myModule" ng-controller="myController">
<p ng-hide="{{hide}}">some text...</p>
<button ng-click="change()">change</button>

And my question: what am I missing?

Answer Source

Remove the brackets around hide in your template.. that will help.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download