HappyCoding HappyCoding - 1 year ago 33
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?


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