ng-disabled
คำสั่งAngularJS
ตัวอย่าง
ปิดการใช้งาน / เปิดใช้งานช่องใส่:
Disable form fields: <input type="checkbox" ng-model="all">
<br>
<input type="text" ng-disabled="all">
<input type="radio" ng-disabled="all">
<select ng-disabled="all">
<option>Female</option>
<option>Male</option>
</select>
ความหมายและการใช้งาน
คำng-disabled
สั่งตั้งค่าแอตทริบิวต์ที่ปิดใช้งานของฟิลด์แบบฟอร์ม (อินพุต เลือก หรือ textarea)
ฟิลด์แบบฟอร์มจะถูกปิดใช้งานหากนิพจน์ภายในng-disabled
แอตทริบิวต์คืนค่าเป็น จริง
จำเป็นต้องมี คำng-disabled
สั่งเพื่อให้สามารถเปลี่ยนค่าระหว่างtrue
และ false
ใน HTML คุณไม่สามารถตั้งค่าdisabled
แอตทริบิวต์เป็นfalse
(การมีอยู่ของแอตทริบิวต์ที่ปิดใช้งานทำให้องค์ประกอบถูกปิดใช้งานโดยไม่คำนึงถึงค่า)
ไวยากรณ์
<input ng-disabled="expression"></input>
รองรับโดย <input>, <select> และ <textarea> องค์ประกอบ
ค่าพารามิเตอร์
Value | Description |
---|---|
expression | An expression that will set the element's disabled attribute if it returns true. |