# Button-bar and active button

**URL:** <https://forum.ionicframework.com/t/button-bar-and-active-button/3584>\
**Category:** ionic-v1\
**Created:** [April 30, 2014, 12:45pm UTC](https://forum.ionicframework.com/t/button-bar-and-active-button/3584 "2014-04-30T12:45:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kfir](https://avatars.discourse-cdn.com/v4/letter/k/9f8e36/32.png) [@kfir](https://forum.ionicframework.com/u/kfir)\
**Post date:** [April 30, 2014, 12:45pm UTC](https://forum.ionicframework.com/t/button-bar-and-active-button/3584/1 "2014-04-30T12:45:36Z")

</div>

How can I make a button active state?  
I tried this:

```
ng-class="{'active': pages, 'unactive': !pages}" ng-click="selectViewInMap('pages'); pages=!pages"

```

I tried jquery but after two seconds the `active` deleted from `class`

---

<div class="post-metadata">

**Author:** ![Calendee](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/calendee/32/13656_2.png) [@Calendee](https://forum.ionicframework.com/u/Calendee)\
**Post date:** [April 30, 2014, 1:06pm UTC](https://forum.ionicframework.com/t/button-bar-and-active-button/3584/2 "2014-04-30T13:06:20Z")

</div>

Try to avoid jQuery at all costs when using AngularJS and Ionic.

Here’s a working sample: [http://codepen.io/calendee/pen/jArnK](http://codepen.io/calendee/pen/jArnK)

```auto
<ion-content padding="true">
	<div class="button-bar">
	  <a class="button" ng-class="{'active' : data.activeButton === 1}">First</a>
	  <a class="button" ng-class="{'active' : data.activeButton === 2}">Second</a>
	  <a class="button" ng-class="{'active' : data.activeButton === 3}">Third</a>
	</div>      
</ion-content>

```

```auto
.controller('MyCtrl', function($scope, $interval) {
  $scope.myTitle = 'Template';
  
  $scope.doSomething = function() {
    $scope.myTitle = $scope.myTitle + ' something';
  };
  $scope.data = {
    activeButton : 1
  }
  
  $interval( function() {
    $scope.data.activeButton = $scope.data.activeButton + 1;
    if($scope.data.activeButton > 3) $scope.data.activeButton = 1;
  }, 2000);

});

```

---

<div class="post-metadata">

**Author:** ![kfir](https://avatars.discourse-cdn.com/v4/letter/k/9f8e36/32.png) [@kfir](https://forum.ionicframework.com/u/kfir)\
**Post date:** [April 30, 2014, 3:38pm UTC](https://forum.ionicframework.com/t/button-bar-and-active-button/3584/3 "2014-04-30T15:38:35Z")

</div>

Thanks so much work!!  
Although not `active` so I opened a new `class`
