SwitchControlSchema
Estimated reading: 3 minutes
255 views

Dùng để tạo 1 toggle switch trong form.
Import
Import vào đầu file .ts cần sử dụng
import { SwitchControlSchema } from 'tnx-shared';
Cách dùng cơ bản
SwitchControlSchema được thêm vào trong this.setting.schema khi khởi tạo form.
Gán giá trị mặc định khi khởi tạo form
new SwitchControlSchema({
label: 'Áp dụng',
fullLabel: 'Áp dụng',
field: 'trangThai',
defaultValue: true
})
new SwitchControlSchema({
field: 'myField',
label: 'Trường muốn dùng',
onChanged: (eventData: EventData) => {
console.log(eventData);
if (this.model.data.property || <>) {
evt.formControls['other control name'].hidden = true;
} else {
evt.formControls['other control name'].hidden = false;
}
},
// nếu là thành viên ngoài trường thì hiện, không phải thì ẩn đi
hiddenCheck: (rootModel, currentNode) => {
return !currentNode.parentNode.parentModel.isThanhVienNgoaiTruong;
},
})