我正在使用 ngbDropdownMenu 指令,我希望能够在某些特殊情况下禁用该指令,例如:
def bubble_sort(unsorted_list):
my_list = list(unsorted_list) # create a copy to avoid mutating the original list
unsorted = True
while unsorted:
unsorted = False
for i in range (len(my_list)-1):
if my_list[i] > my_list[i+1]:
unsorted = True
my_list[i] , my_list[i+1] = my_list[i+1], my_list[i]
return my_list
unsorted_list = [5,2,4,90,140,23,554,32,98,12,15,0,43,-34,10]
print(bubble_sort(unsorted_list))
答案 0 :(得分:1)
不,您不能,ngbDropdownMenu
并非旨在接受条件,但是您可以这样做:
<ng-container *ngIf="<someCondition> else someTemplate">
<div [ngbDropdownMenu]> </div>
...
</ng-container>
<ng-template #someTemplate>
<div>something else to show if condition is not met</div>
</ng-template>