Apple Pie Apple Pie - 1 year ago 145
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

Answer Source

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;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download