Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 我想将一个bootstrap4类绑定到表单字段_Angular_Bootstrap 4_Angular Reactive Forms_Angular Bootstrap - Fatal编程技术网

Angular 我想将一个bootstrap4类绑定到表单字段

Angular 我想将一个bootstrap4类绑定到表单字段,angular,bootstrap-4,angular-reactive-forms,angular-bootstrap,Angular,Bootstrap 4,Angular Reactive Forms,Angular Bootstrap,我只是想在Angular form字段无效并被触碰时绑定bootstrap4类“is invalid”。 为此我试过= <input type="text" #name class="form-control" [class.is-invalid]="name.invalid && name.touched" name="Name" [(ngModel)]='users.username' required> 实际上,这个表单是关于更新地址的,所以我已经用ng

我只是想在Angular form字段无效并被触碰时绑定bootstrap4类“is invalid”。 为此我试过=

<input type="text" #name class="form-control" [class.is-invalid]="name.invalid && name.touched" name="Name" [(ngModel)]='users.username'  required>

实际上,这个表单是关于更新地址的,所以我已经用ngModel绑定了用户名,这个表单就像Amazon或flipkat一样,您可以在其中编辑您的地址

但是使用, [class.is invalid]=“name.invalid&&name.toucted”在上述代码中无效

尝试使用
#name=“ngModel”


此字段必填
尝试使用
\name=“ngModel”


此字段必填
<input type="text" #name="ngModel" class="form-control" name="Name" required>
<small [class.d-none]='name.valid || name.untouched'>This field is required</small>