Farris Ismati Farris Ismati - 11 months ago 30
AngularJS Question

How to change an object's property in AngularJS

I have a function that sets a property in an object to false if it's true and true if it's false. Yet every time the function runs the object doesn't get affected.

$scope.menuButtons = [{header: "beaded", isActive: false},
{header: "laced", isActive: false}

$scope.activeButton = function(isActive) {
isActive == true ? isActive = false : isActive = true;

Here's the HTML

<div ng-repeat="b in menuButtons">

<div ng-click="activeButton(b.isActive)" class="shop-navbar-button">{{b.header}}</div>


I'm using the isActive value to see if the button is active so I can use a different class. For some reason the isActive value in the $scope doesn't get affected.


Pass in b instead of b.isActive. The boolean is just being passed by value, so re-assigning the value will have no effect on b.isActive.