我正在使用带有angular2的asp.net核心应用程序,我的路由工作正常.
<a target="target" routerLink="/page1" routerLinkActive="active">Associates</a>
<a routerLink="/page2" routerLinkActive="active">Account managers</a>
Run Code Online (Sandbox Code Playgroud)
我想在新标签页中打开每个页面链接(routerLink).是否可能在新选项卡中打开每个链接,而无需刷新页面?
我试图替换routerLink="/Page2",target="target" href="/associates"但页面刷新所有引用.
我使用了Reactive form Validation(模型驱动的验证),但是无法在Dropdown更改时将值设置为form对象
这是我的Formgroup
studentModel:StudenModel
AMform: FormGroup;
Name = new FormControl("", Validators.required);
Address = new FormControl("", Validators.maxLength(16));
constructor(fb: FormBuilder){
this.AMform = fb.group({
"Name": this.Code,
"Address": this.Abbrev,
});
}
onAccntChange(event: Event) {
// set the value from Class Model
//// this.studentModel
// how to set this.studentModel value to form
}
Run Code Online (Sandbox Code Playgroud)
这是我的html页面
<form [formGroup]="AMform" (ngSubmit)="submit()">
<select (change)="onAccntChange($event)" class="form-control" [disabled]="ddlActivity" formControlName="AccountManagerID">
<option value="0">Select</option>
<option *ngFor="let item of allStudent" value={{item.StudentID}}>
{{item.Name}}
</option>
</select>
<div class="col-sm-9">
<input type="text" class="form-control" formControlName="Name">
</div>
<div [hidden]="Name.valid || Code.pristine" …Run Code Online (Sandbox Code Playgroud) 在按钮上单击我必须发布和发送学生对象,所以请告诉我如何将 formGroup 对象绑定到 ModelClass 对象,不想手动将数据一一添加到变量中。我必须以单一方式绑定,而不是手动绑定。
这是我的 formGroup 对象
this.AMform = fb.group({
"Name": new FormControl("", [Validators.required, Validators.maxLength(10) ]),
"Code":new FormControl("", [Validators.required, Validators.maxLength(10) ]),
"Address": new FormControl("", [Validators.required, Validators.maxLength(10) ])
});
Run Code Online (Sandbox Code Playgroud)
这是我的模型
class Student
{
public Name: string="";
public Code: string="";
public Äddress: string="";
}
Run Code Online (Sandbox Code Playgroud)