残疾人无法正常工作 [英] Disabled not working

查看:97
本文介绍了残疾人无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 不起作用:
    • [disabled] = true
    • [disabled] = "isDisabled" ----- ts>(isDisabled = true)
    • 基本html禁用器也无法正常工作---- html> disable
    • [attr.disabled] = true
    • [attr.disabled] = "isDisabled" ----- ts>(isDisabled=true)
  1. Not working :
    • [disabled] = true ,
    • [disabled] = "isDisabled" -----ts > ( isDisabled=true)
    • basic html disabler also not wokring ----html > disable
    • [attr.disabled] = true ,
    • [attr.disabled] = "isDisabled" -----ts > ( isDisabled=true)

我正在尝试为预览和更新创建相同的表单(预览应禁用输入),但是我在html中的输入无法绑定到typescript布尔值. 在html中,我有一个表,其中包含person.name,person.surname....button(preview),button(update)都触发onSelect函数并发送person + true/false.

I'm trying to make same form for preview and update (preview should have disabled inputs), but my input in html fails to bind to typescript boolean. In html I have a table with person.name, person.surname .... button(preview), button(update) both triggering the onSelect function and sending person + true/false.

<input [(ngModel)]="osoba.ime" [attr.disabled]="isDisabled" name = "ime" type="text" id="ime">

和打字稿功能和属性

isDisabled = true;

onSelect(o: Osoba, isView) {
    this.isDisabled = isView;
    console.log(document.getElementById('ime'));
    console.log(this.isDisabled);
    this.selectedOsoba = o;
}

this.isDisabled的日志有效

log of this.isDisabled is valid

但是元素的日志甚至没有禁用的属性

but log of the element doesn't even have disabled property

<input _ngcontent-c5="" id="ime" name="ime" type="text" ng-reflect-name="ime" ng-reflect-model="Dusan     " class="ng-untouched ng-pristine ng-valid">

这是完整的html代码

here's the whole html code

<form *ngIf="osoba">
  <div class="input">
    <label>Ime Osobe</label>
    <input [disabled]= "isDisabled" [(ngModel)]="osoba.ime" name = "ime" type="text" id="ime">
  </div>
  <div class = "input">
    <label >Prezime Osobe</label>
    <input [(ngModel)]="osoba.prezime"  name = "prezime" type="text" id = "prezime" [disabled] = "isDisabled">
  </div>
  <div >
      <label >Jmbg Osobe </label>
      <input  [(ngModel)]="osoba.jmbg" name = "jmbg" type="text" [attr.disabled]= true >
    </div>
  <div class="input">
    <input type="submit" value="izmeni" (click)="updateOsoba()">
  </div>
</form>
<input id="disabledTest" type="text" value="nekiTekst" [disabled]= true>

该表格以外的输入有效,但form和div中的所有输入均无效 有什么收获?

the input which is out of the form is working , but all inputs in form and divs not working what's the catch ?

推荐答案

使用attr.disabled时,必须提供文字值或完全省略属性.请记住,HTML中的disable属性禁用了仅通过显示即可支持该属性的元素.

When using attr.disabled, you have to supply the literal value, or omit the attribute altogether. Bear in mind that the disabled attribute in HTML disables an element that supports the attribute simply by being present.

<input [(ngModel)]="osoba.ime" [attr.disabled]="disabled?'':null" name="ime" type="text" id="ime">

HTML中的以下两项均应导致输入被禁用...

Both of the following in HTML should result in an input being disabled...

<input disabled />
<input disabled="disabled" />

这篇关于残疾人无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆