我的导航栏,
Opt('WinTitleMatchMode', 2) ;ensure partial window title matches on and WinActivate, WinExists, WinWait, WinWaitActive, WinKill commands
; code to load chrome via Run dialog goes here
WinWaitActive("Chrome")
sleep(500)
send("^a") ;select all on the browser's active tab
sleep(250)
send("^c") ;copy it into the clipboard
sleep(250)
Local $webPageContents = ClipGet()
; if statement or while loop to check for the existence of some string of content on the webpage
同样,我的html中有5到6个导航栏。现在,我需要为特定页面显示特定的导航栏。单个if条件(* ngIf =“ path ==='/ aa'”)似乎有效,如果我给出多个条件,它将不起作用。你能帮我吗?
答案 0 :(得分:1)
您应该使用具有多个值的ngSwitch
<div [ngSwitch]="path">
<div *ngSwitchCase="'/login'">...</div>
<div *ngSwitchCase="'/home'">...</div>
</div>
答案 1 :(得分:1)
我在这里创建了一个Stackblitz演示
我认为您在* ngIf引号中做错了
答案 2 :(得分:0)
如果每次使用的数据可能都不同,那么大多数情况下,请使用If
。但是如果不是在每个地方都行。最好在代码中使用switch-case
,例如:
public string TestSwitchCase(string value)
{
switch (value)
{
case "John":
return null;
case "Jack":
return "Jack";
default:
break;
}
return null;
}
现在已成角度,最好的方法是在HTML
代码中执行此操作。这是ngSwitch
,用法如:
<container-element [ngSwitch]="switch_expression">
<some-element *ngSwitchCase="match_expression_1">...</some-element>
<some-element *ngSwitchCase="match_expression_2">...</some-element>
<some-other-element *ngSwitchCase="match_expression_3">...</some-other-element>
<ng-container *ngSwitchCase="match_expression_3">
<!-- use a ng-container to group multiple root nodes -->
<inner-element></inner-element>
<inner-other-element></inner-other-element>
</ng-container>
<some-element *ngSwitchDefault>...</some-element>
</container-element>
有关更多信息,请参见:This
祝你好运。
答案 3 :(得分:0)
[SOLUTION]:只需使用“ &&”运算符即可在* ngIf-
中添加多个条件
//TypeScript File - demo.ts
//Declaration
flag: any;
temp_array = [];
//Assignment
this.flag = true;
this.temp_array = [1,2];
<!--HTML File - demo.html-->
<div *ngIf="flag && temp_array.length>0">
Both *ngIf conditions passes
</div>