简体   繁体   English

在没有使用Angular2或Typescript找不到部门的情况下如何打开警报对话框

[英]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.

相关问题 使用angular2或打字稿输入时如何避免重复数据 - How to avoid repeat of data when entered using angular2 or typescript 如何使用angular2和Typescript使选定的下拉值在更改时显示在标题上 - How to make the selected dropdown value to display on the header on change using angular2 and typescript 如何使用angular2或typescript使编辑器文本获取与json数据相同的数据 - how to make the editor text to get the data same as json data using angular2 or typescript 在angular2 / typescript中使用jointjs - Using jointjs in angular2/typescript 使用Angular2 / typescript发生未定义的错误时如何将页面重定向到登录页面 - How to redirect the page to login page when the undefined error occurs using Angular2/typescript 如何使jQuery ui对话框像警告或确认框一样停止浏览器处理? - How to make jQuery ui dialog box halt browser processing like an alert or confirmation box? 使用angular2显示引导程序警报 - Displaying bootstrap alert using angular2 如何使用angular2和Typescript对页面进行身份验证 - How to do authentication for pages using angular2 and typescript JavaScript:单击SVG元素时如何显示警报对话框? - JavaScript: How to make an alert dialog appear when clicking an SVG element? 如何使用Angular2和Typescript在表中添加和更新条目 - How to Add and Update entries in Tables using Angular2 and Typescript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM