[英]How to make alert dialog box to open when there is no department found using Angular2 or Typescript
I have a department section, if i have no departments found in that then i must get a dialog box saying "No department found". 我有一个部门部门,如果我在那没有部门,那么我必须得到一个对话框,提示“未找到部门”。 I am here by sharing my HTML and ts code.
我在这里共享我的HTML和ts代码。 Please help
请帮忙
HTMl: HTMl:
<div class="form-group">
<ng-select [options]="departments" (click)="checkDepartment(departments)" notFoundMsg="No Departments Found" name="department" >
</ng-select>
</div>
Ts: Ts:
checkDepartment(check){
console.log(check);
console.log(check);
if(check == 0){
this.dialog.open(Department);
}
}
If I am correct you are already using Bootstrap. 如果我是正确的,那么您已经在使用Bootstrap。 There is a Bootstrap module for Angular.
有一个用于Angular的Bootstrap模块 。 You could use the Modal here.
您可以在此处使用Modal 。
In the component where you have the ng-select
implement AfterViewInit
and add the ngAfterViewInit
method. 在具有
ng-select
的组件中,实现AfterViewInit
并添加ngAfterViewInit
方法。 There you can check the department size and if it is empty open the modal. 在那里,您可以检查部门规模,如果为空,请打开模式。
export class PageComponent implements AfterViewInit {
ngAfterViewInit() {
if (department.length === 0) {
// Open modal
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.