Angular CLI项目Bootstrap has-success或has-danger类未加载

问题描述 投票:1回答:1

我对社区有另一个问题,这个问题很简单。如前所述,我正在研究Asim Hussain先生的“Angular4 From Theory to Practice”一书,并遇到了bootstrap .has-danger和.has-success类无法正常工作的问题。我安装了bootstrap

npm install bootstrap --save

在.angular-cli.json中添加了bootstrap css的路径

"styles": [
      "../node_modules/bootstrap/dist/css/bootstrap.min.css",
      "styles.css"
   ],

一切似乎都运行良好,网格和表单样式加载良好,控制台没有错误。当我在练习后实现验证时,问题出现了,表单字段边框不会变为红色或绿色,这是我的代码

<!-- One of the fields from the form -->
 <div class="form-group"
    [ngClass]="{
        'has-danger': f.form.controls.email?.invalid && (f.form.controls.email?.dirty || f.form.controls.email.touched),
        'has-success': f.form.controls.email?.valid && (f.form.controls.email?.dirty || f.form.controls.email.touched)

    }">
        <label>Email</label>
        <input type="email"

               class="form-control"
                     name="email"
                     [(ngModel)]="model.email"
                     required
                     pattern="[^ @]*@[^ @]*">
    </div>

不知道为什么bootstrap类没有将文本字段变为红色或绿色,有人可以帮我解决这个问题吗?

angularjs-directive
1个回答
0
投票

问题是7个月大,但回应可能有助于其他人。

.has-danger不再存在。这个问题已在这里提出:

has-danger no longer working on Bootstrap v4 beta?

© www.soinside.com 2019 - 2024. All rights reserved.