admin管理员组文章数量:1310498
How can i disable the button present in the template from the ponents properties? suppose i have a ponent like this
export class PolicyAddComponent {
ToggleButton: boolean = true;
SubmitPolicy(value: any) {
ToggleButton = false;
}
}
and i have a template like this
<form role="form" [formGroup]="PolicyForm" (ngSubmit)="SubmitPolicy(PolicyForm.value)">
<input type="date" class="form-control" formControlName="RateDate" placeholder="Rate Date">
<button type="submit" class="btn btn-primary">Submit</button>
<button type="submit" class="btn btn-primary" (click)="ShowIssuedPolicy()">Show Issue policy</button>
</form>
I want the submit button to be disabled and the Show Issue policy button to be enabled once the submit button is clicked. How can i do that?
How can i disable the button present in the template from the ponents properties? suppose i have a ponent like this
export class PolicyAddComponent {
ToggleButton: boolean = true;
SubmitPolicy(value: any) {
ToggleButton = false;
}
}
and i have a template like this
<form role="form" [formGroup]="PolicyForm" (ngSubmit)="SubmitPolicy(PolicyForm.value)">
<input type="date" class="form-control" formControlName="RateDate" placeholder="Rate Date">
<button type="submit" class="btn btn-primary">Submit</button>
<button type="submit" class="btn btn-primary" (click)="ShowIssuedPolicy()">Show Issue policy</button>
</form>
I want the submit button to be disabled and the Show Issue policy button to be enabled once the submit button is clicked. How can i do that?
Share Improve this question edited Jul 10, 2017 at 8:49 kind user 41.9k8 gold badges68 silver badges78 bronze badges asked Feb 27, 2017 at 13:45 Lijin DurairajLijin Durairaj 3,51112 gold badges34 silver badges52 bronze badges2 Answers
Reset to default 4One of the ways how to achieve it is to implement a boolean
variable, which will hold a true
value until the user has clicked and seen the Issue policy
. Then, the variable sets into false
and the submit button is enabled.
<button type="submit" class="btn btn-primary" [disabled]='checkPolicy'>Submit</button>
<button type="button" class="btn btn-primary" (click)="ShowIssuedPolicy()">Show Issue policy</button>
checkPolicy: boolean = true;
ShowIssuedPolicy(){
this.checkPolicy = false;
}
Plunker link
You could do that using the following:
Componentexport class PolicyAddComponent{
ToggleButton: boolean = true;
SubmitPolicy(value: any) {
ToggleButton=false;
}
}
Template
<form role="form" [formGroup]="PolicyForm" (ngSubmit)="SubmitPolicy(PolicyForm.value)">
<input type="date" class="form-control" formControlName="RateDate" placeholder="Rate Date">
<button type="submit" class="btn btn-primary" (click)="SubmitPolicy()">Submit</button>
<button type="submit" class="btn btn-primary" (click)="ShowIssuedPolicy()" [disabled]="ToggleButton">Show Issue policy</button>
</form>
本文标签: javascriptHow to disable a button from the component in angular2Stack Overflow
版权声明:本文标题:javascript - How to disable a button from the component in angular2? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741817944a2399188.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论