How do I use conditionals in Angular Expressions with ngDisable?

Batman

I have a DOM button which is disabled when there is no user selected (it's set to false on load) However, I also need to disable this button when an array is empty. For example I have an array of groups, when all groups have been added, I'd like to disable the add button.

        <div>
            <label for="entityAvailable">Available Groups</label>
            <select id="entityAvailable" multiple   
                ng-model="selectedAvailableGroups" 
                ng-options="g.name for g in availableGroups | orderBy:'name'">
            </select>
        </div>
        <div id="moveButtons" >
            <button type="button" ng-disabled="!selectedUser || availableGroups == []" ng-click="addUserToGroup()">Add User</button>
            <button type="button" ng-disabled="!selectedUser" ng-click="removeUserFromGroup()">Remove</button>
        </div>
        <div>
            <label for="entityAssigned">Assigned Groups</label>
            <select id="entityAssigned" multiple
                ng-model="selectedAssignedGroups" 
                ng-options="g.name for g in assignedGroups | orderBy:'name'">                       
            </select>
        </div>
Tasnim Reza

You can do

ng-disabled="!selectedUser || availableGroups.length == 0"

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to use conditionals with lists

From Dev

How do you use conditionals within iterations using Jade?

From Dev

How can I use multiple conditionals and match to create a new variable?

From Dev

How do i use regular expressions in python lxml, XPath

From Dev

How do I use multiple wildcard reg expressions in notepad++

From Dev

How do I use Bluebird with Angular?

From Dev

How do I use oncopy in Angular?

From Dev

How do I use angular directives as comments?

From Dev

How do I use jquery in an angular directive

From Dev

What is fileAPI ? How do I use it with angular?

From Dev

How to use logstash conditionals(if...in) correctly?

From Dev

How do I avoid repetitive inline conditionals for defining htmlAttributes of Html.EditorFor()

From Dev

How can I use regular expressions

From Dev

How do I use regular expressions in PostgreSQL to remove the end of a field matching pattern?

From Dev

How do I use XPath expressions when querying from a XML attribute in a Oracle database

From Dev

How do I match URLs with regular expressions?

From Dev

How do I use jsonp with angular-ui calendar

From Java

How do I use $rootScope in Angular to store variables?

From Dev

How do I use the angular date filter with Kendo template?

From Dev

How do I use an angular-js $resource?

From Dev

How do I do a "contains" query with f# query expressions?

From Java

Thymeleaf: how to use conditionals to dynamically add/remove a CSS class

From Dev

How to use conditionals when replacing in Notepad++ via regex

From Dev

how to use jade/pug conditionals inside a script block?

From Dev

How to use advance Ansible playbook conditionals to parse json?

From Dev

How do the MVC html helpers use expressions to get an objects property

From Dev

How do the MVC html helpers use expressions to get an objects property

From Dev

How do you use regular expressions with the cp command in Linux?

From Dev

Use of conditionals in Prolog

Related Related

  1. 1

    How to use conditionals with lists

  2. 2

    How do you use conditionals within iterations using Jade?

  3. 3

    How can I use multiple conditionals and match to create a new variable?

  4. 4

    How do i use regular expressions in python lxml, XPath

  5. 5

    How do I use multiple wildcard reg expressions in notepad++

  6. 6

    How do I use Bluebird with Angular?

  7. 7

    How do I use oncopy in Angular?

  8. 8

    How do I use angular directives as comments?

  9. 9

    How do I use jquery in an angular directive

  10. 10

    What is fileAPI ? How do I use it with angular?

  11. 11

    How to use logstash conditionals(if...in) correctly?

  12. 12

    How do I avoid repetitive inline conditionals for defining htmlAttributes of Html.EditorFor()

  13. 13

    How can I use regular expressions

  14. 14

    How do I use regular expressions in PostgreSQL to remove the end of a field matching pattern?

  15. 15

    How do I use XPath expressions when querying from a XML attribute in a Oracle database

  16. 16

    How do I match URLs with regular expressions?

  17. 17

    How do I use jsonp with angular-ui calendar

  18. 18

    How do I use $rootScope in Angular to store variables?

  19. 19

    How do I use the angular date filter with Kendo template?

  20. 20

    How do I use an angular-js $resource?

  21. 21

    How do I do a "contains" query with f# query expressions?

  22. 22

    Thymeleaf: how to use conditionals to dynamically add/remove a CSS class

  23. 23

    How to use conditionals when replacing in Notepad++ via regex

  24. 24

    how to use jade/pug conditionals inside a script block?

  25. 25

    How to use advance Ansible playbook conditionals to parse json?

  26. 26

    How do the MVC html helpers use expressions to get an objects property

  27. 27

    How do the MVC html helpers use expressions to get an objects property

  28. 28

    How do you use regular expressions with the cp command in Linux?

  29. 29

    Use of conditionals in Prolog

HotTag

Archive