有没有办法在按下表单上的按钮时显示新的 mdDialog?
Is there a way to show a new mdDialog when a button is pressed on a form?
我正在制作一个网络应用程序,而不是在按下提交按钮时路由到一个全新的页面,我只想在我已有的 mdDialog 或表单上显示其他内容。
到目前为止,我基本上只是在计划它,但我拥有的一些伪代码是这样的:
HTML:
<form [formGroup]="firstFormUserSees">
**input containers and what not**
</form>
<div>
<button md-raised-button (click)="submit()"[disabled]="firstFormUserSees.invalid>Submit</button>
</div>
<form [formGroup]="secondFormUserSees" *ngIf= **something**>
**second form stuff here**
</form>
并且在 typeScript 中会有一个名为 submit() 的方法,但我只是不确定如何去做并且我是 TS 的新手并且 angular 2
您可以使用 *ngIf
.
例如:
在你的构造函数之上:
show_my_form = true;
HTML
<form [formGroup]="firstFormUserSees" *ngIf="show_my_form">
**input containers and what not**
</form>
<div>
<button md-raised-button (click)="submit()"[disabled]="firstFormUserSees.invalid>Submit</button>
</div>
<form [formGroup]="secondFormUserSees" *ngIf= **something**>
**second form stuff here**
</form>
并且在提交后触发的函数中
this.show_my_form = false;
您可以通过更改布尔值来显示和隐藏内容。在您的情况下,隐藏表单并显示另一个元素。 (您还需要为其他元素创建一个布尔值)
我正在制作一个网络应用程序,而不是在按下提交按钮时路由到一个全新的页面,我只想在我已有的 mdDialog 或表单上显示其他内容。
到目前为止,我基本上只是在计划它,但我拥有的一些伪代码是这样的:
HTML:
<form [formGroup]="firstFormUserSees">
**input containers and what not**
</form>
<div>
<button md-raised-button (click)="submit()"[disabled]="firstFormUserSees.invalid>Submit</button>
</div>
<form [formGroup]="secondFormUserSees" *ngIf= **something**>
**second form stuff here**
</form>
并且在 typeScript 中会有一个名为 submit() 的方法,但我只是不确定如何去做并且我是 TS 的新手并且 angular 2
您可以使用 *ngIf
.
例如:
在你的构造函数之上:
show_my_form = true;
HTML
<form [formGroup]="firstFormUserSees" *ngIf="show_my_form">
**input containers and what not**
</form>
<div>
<button md-raised-button (click)="submit()"[disabled]="firstFormUserSees.invalid>Submit</button>
</div>
<form [formGroup]="secondFormUserSees" *ngIf= **something**>
**second form stuff here**
</form>
并且在提交后触发的函数中
this.show_my_form = false;
您可以通过更改布尔值来显示和隐藏内容。在您的情况下,隐藏表单并显示另一个元素。 (您还需要为其他元素创建一个布尔值)