Apple Pie Apple Pie - 2 months ago 49
AngularJS Question

Ternary operator on aria-expanded angularjs

I am trying to add aria-expanded to a link, I want the value of aria-expanded to be true when the user has expanded the link and false when it's not. I am not sure how to achieve this, i think a ternary operator would do but not sure how.

<a href="" ng-click="do()" class="" aria-expanded="{{}}" aria-label="test">
<span class=""></span>Something


You can simply bind the property to a variable

<a href="" ng-click="do()" class="" aria-expanded="{{expandedValue}}" aria-label="test">
  <span class="">Something</span>

In your controller

$ = function(){
    $scope.expandedValue = !$scope.expandedValue;