html中的
required hidden readonly disabled
这些属性,动态启用禁用
<
div
class=
"form-group" [
hidden]=
"model.isPersistent"
>
<
label
for=
"idletimeout"
>IdleTimeOut
</
label
>
<
input
type=
"text"
class=
"form-control"
id=
"idletimeout" [(
ngModel)]=
"model.idleTimeout" [
required]=
"!model.isPersistent"
name=
"idleTimeout"
value=
'60' #
idletimeout=
"ngModel"
>
<
div [
hidden]=
"idletimeout.valid || idletimeout.pristine"
class=
"alert alert-danger"
>
IdleTimeOut is required
</
div
>
</
div
>
<
button
type=
"submit"
class=
"btn btn-success" [
disabled]=
"!addEditWorkStationForm.form.valid"
>Submit
</
button
>
原理不多说,先会用再说啦