【问题标题】:Bootstrap UI Angular modal doesn't show as a pop upBootstrap UI Angular 模态不显示为弹出窗口
【发布时间】:2017-03-24 15:08:21
【问题描述】:

我有什么:https://rawgit.com/emilyeserven/testwebsites/master/js/angular/chara-select/index.html

底部是打开模式框的按钮。但是,当它们被点击时,它们只会显示在顶部,而不仅仅是引导按钮样式。

目前的模态代码改编自Bootstrap UI demo site(我只是改了app模块的名字)。未修改的代码在 MAMP 的沙箱中测试了代码,所以我知道它有效。我不确定问题出在哪里,因为控制台没有显示任何异常错误。

任何直接与模态相关的 HTML 代码都在 index.html 的底部。同样,任何直接与模态相关的 JS 都在 js/modal.js 中。

GitHub 存储库:https://github.com/emilyeserven/testwebsites/tree/master/js/angular/chara-select

任何帮助我指出正确的方向将不胜感激!

【问题讨论】:

标签: javascript angularjs angular-ui-bootstrap


【解决方案1】:

<mat-toolbar>
  <span>{{service.form.controls['$key'].value?"Modify Employee":"New Employee"}}</span>
  <span class="fill-remaining-space"></span>
  <button class="btn-dialog-close" mat-stroked-button (click)="onClose()" tabIndex="-1"><mat-icon>clear</mat-icon></button>
</mat-toolbar>
<form [formGroup]="service.form" class="normal-form" (submit)="onSubmit()">
  <mat-grid-list cols="2" rowHeight="300px">
    <mat-grid-tile>
      <div class="controles-container">
        <input type="hidden" formControlName="$key">
        <mat-form-field>
          <input formControlName="fullName" matInput placeholder="Full Name*">
          <mat-error>This field is mandatory.</mat-error>
        </mat-form-field>
        <mat-form-field>
          <input formControlName="email" matInput placeholder="Email">
          <mat-error>Invalid email address.</mat-error>
        </mat-form-field>
        <mat-form-field>
          <input formControlName="mobile" matInput placeholder="Mobile*">
          <mat-error *ngIf="service.form.controls['mobile'].errors?.required">This field is mandatory.</mat-error>
          <mat-error *ngIf="service.form.controls['mobile'].errors?.minlength">Minimum 8 charactors needed.</mat-error>
        </mat-form-field>
        <mat-form-field>
          <input formControlName="city" matInput placeholder="City">
        </mat-form-field>
      </div>
    </mat-grid-tile>
    <mat-grid-tile>
      <div class="controles-container">
        <div class="add-bottom-padding">
          <mat-radio-group formControlName="gender">
            <mat-radio-button value="1">Male</mat-radio-button>
            <mat-radio-button value="2">Female</mat-radio-button>
            <mat-radio-button value="3">Other</mat-radio-button>
          </mat-radio-group>
        </div>
        <mat-form-field>
          <mat-select formControlName="department" placeholder="Department">
            <mat-option>None</mat-option>
            <ng-container *ngFor="let department of departmentService.array">
              <mat-option value="{{department.$key}}">{{department.code}}-{{department.name}}</mat-option>
            </ng-container>
          </mat-select>
        </mat-form-field>
        <mat-form-field>
          <input formControlName="hireDate" matInput [matDatepicker]="picker" placeholder="Hire Date">
          <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
          <mat-datepicker #picker></mat-datepicker>
        </mat-form-field>
        <div class="add-bottom-padding">
          <mat-checkbox formControlName="isPermanent">Permanent Employee</mat-checkbox>
        </div>
        <div class="button-row">
          <button mat-raised-button color="primary" type="submit" [disabled]="service.form.invalid">Submit</button>
          <button mat-raised-button color="warn" (click)="onClear()">Clear</button>
        </div>
      </div>
    </mat-grid-tile>
  </mat-grid-list>
</form>

【讨论】:

  • 检查您是否可以调整对所提问题的回答。在问题要求 angularjs 的地方,你的似乎是有角度的。尝试将一些 cmets 添加到您的 sn-p 中,以帮助读者了解正在发生的事情以及它如何帮助解决问题。
  • .col-xl-6 { -webkit-box-flex : 0; -webkit-flex:0 0 50%; -moz-box-flex:0; -ms-flex:0 0 50%;弹性:0 0 50%;最大宽度:50%; }
【解决方案2】:

据我所知,您正在使用自定义构建的引导程序。 它不包含任何模式的样式。 尝试加载 https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css 而不是 bootstrap.css,它会起作用。

【讨论】:

  • 就是这样,非常感谢! GitHub 存储库已更新。 :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多