0
<span class="column__list--total fa" ng-class="{'fa-check': skill.done == 1, 'fa-times red': skill.done == 0}" ng-click="skill.disabled || toggleSkill(skill.id, person.id)" ng-hide="$root.user[0].auth == 2"></span>

<span class="column__list--total fa" ng-class="{'fa-check': skill.done == 1, 'fa-times red': skill.done == 0}" ng-show="$root.user[0].auth == 2"></span>

At the moment I am using the above, they are equally the same but one will be hidden using ng-hide when a variable equals 2

The reason being I want to disable ng-click on the element.

Do I need to keep it as two separate elements or is it possible to disable ng-click when $root.user[0].auth == 2

2 Answers 2

2

You already have a condition in your ng-click, why not add another?

ng-click="$root.user[0].auth == 2 || skill.disabled || toggleSkill(skill.id, person.id)"

Sign up to request clarification or add additional context in comments.

Comments

0

You can just do return; in your toggleSkill() before executing any other code.

$scope.toggleSkill = function(skill.id, person.id) {
    if ($root.user[0].auth == 2) {
        return;
    }

    // Rest of your code
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.