-2

I want to hide this tag when it doesn't have a subcategory, I used item.length != 0 but it doesn't work.

    <multi-select-tree class="multiselectStyle groupStyle" 
           data-input-model="categoryTree" 
           multi-select="true" data-output-model="selectAllCategory"
           ng-show="item.length!=0" //is wrong! 
           data-default-label="select article group"
           data-callback ="selectOnlyCategory(item, selectedItems)">
    </multi-select-tree>

    $scope.selectOnlyCategory = function(item, selectedItems) {
        if (selectedItems !== undefined && selectedItems.length >= 20) {
            return false;
        } else {
            return true;
        }
    };
  • Item is as entrance value in "selectOnlyCategory(item, selectedItems)" –  Jan 24 '17 at 08:49
  • @mahdikhodadadian please include some code to explain the structure of your `item`. – Soviut Jan 24 '17 at 08:49
  • Is this an object ? Please update your question with the item. Where is the subcategory ? – Weedoze Jan 24 '17 at 08:49
  • can you post you categoryTree with some dummy json – Mitesh Pant Jan 24 '17 at 08:57
  • why are you passing 'item' as a parameter if you don't use it? – Joe Jan 24 '17 at 08:58
  • Subcategory generate in it , like this : –  Jan 24 '17 at 08:59
  • If it is false say to me what I should pass except item ? –  Jan 24 '17 at 09:01
  • @mahdikhodadadian I think that you should ask a friend/colleague to help you to ask a well-formed question. You are absolutely not clear and you don't understand our remarks – Weedoze Jan 24 '17 at 09:10
  • @Weedoze Ok Thanks –  Jan 24 '17 at 09:14
  • Possible duplicate of [How do I set the value property in AngularJS' ng-options?](http://stackoverflow.com/questions/12139152/how-do-i-set-the-value-property-in-angularjs-ng-options) –  Mar 03 '17 at 11:02

1 Answers1

1

try to use data-ng-if, this will keep your html light, the item is not even generated if the condition is not met try to do this. Assumption : your controller is passing some value to $scope.item

data-ng-if="item.length > 0"
Mitesh Pant
  • 524
  • 2
  • 15