Trang tài liệu Trí Nam

Nếu debug là quá trình loại bỏ bug trong phần mềm, thì code chính là quá trình gây ra bug

TextControlSchema

Estimated reading: 3 minutes 623 views

Hình ảnh / Demo

Link demo: evrwhere

Mục đích

Tạo một ô input trong form.

Cách dùng

Import

Import vào đầu file .ts cần sử dụng

				
					import { TextControlSchema } from 'tnx-shared';
				
			

Cách dùng cơ bản

TextControlSchema được thêm vào trong this.setting.schema khi khởi tạo form.

				
					...
ngOnInit() {
...
this.setting.schema = [
  new TextControlSchema({
      field: 'myField',
      label: 'Trường muốn dùng'
  }),
  ...
]
...
}
...
				
			

Chọn tất cả text khi focus

				
					...
new TextControlSchema({
  field: 'myField',
  label: 'Trường muốn dùng',
  selectedAllText: true
}),
...
				
			

Khi focus thì tự động chọn tất cả text trong field để có thể xóa hết đi nếu cần

Khi muốn lấy thêm trường khác

				
					...
new TextControlSchema({
  field: 'myField',
  label: 'Trường muốn dùng',
  selectedAllText: true,
  fieldPlus: 'id, name, createDate'
}),
...
				
			

Format input (number, email...)

Thay đổi format nhập liệu, các kiểu format hỗ trợ: ‘text’ | ‘password’ | ‘number’ | ’email’ | ‘phone’ | ‘fax’ | ‘money’ | ‘moneyint’ | ‘amount’ = ‘text’

				
					...
new TextControlSchema({
  field: 'myField',
  label: 'Trường muốn dùng',
  dataFormat: 'email'
}),
...
				
			

Thuộc tính

Sự kiện

				
					new TextControlSchema({
  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;
    }
  }
})
				
			
CONTENTS