我正在尝试更改数据绑定的值,并且也在屏幕上更改该值,但是我没有得到它。
我的export function onPageLoaded(args: EventData) {
main = <Page>args.object;
main.bindingContext = fromObject({
loading: false,
next: true,
prev: false,
count: 0,
percent: 10,
dataBoundVariable: null,
form_hemodialysis: null,
form_hemoderivatives: null,
form_special_medicine: null,
form_medicine: null,
form_antibiotics: null,
form_bandaid: null,
form_speech_therapy: null,
form_motor_therapy: null,
form_respiratory_therapy: null,
form_other_therapy: null,
form: {
patientStatus: null,
reason: null,
assistantDoctor: null,
council: null,
hospitalizationTypeId: null,
hospitalizationDate: '6/1/2019',
cidId: null,
accommodationId: null,
hda: null,
diagnosis: null,
speechtherapy_start_date: null,
speechtherapy_frequency: null,
motortherapy_start_date: null,
motortherapy_frequency: null,
respiratorytherapy_start_date: null,
respiratorytherapy_frequency: null,
othertherapy_start_date: null,
othertherapy_frequency: null,
procedures: [],
antibiotics_name: null,
antibiotics_start_date: null,
antibiotics_end_date: null,
antibiotics_prescription: null,
comment: null,
special_medicament: null,
medicine: null,
diets: [],
gasotherapies: [],
dressings: array,
procedure
},
status: [
'Alta',
'Internado',
'Não encontrado'
],
reasons: [],
internationTypes: [],
accommodations: [],
diets: [],
cdi: ['Rafael', 'Deivid'],
gasotherapies: [],
bandaidPhases: ['I', 'II', 'III', 'IV'],
bandaid: {
phase: null,
region: null,
lesion_width: null,
lesion_length: null,
used_cover: null,
expected_exchange: null
},
procedure: {
name: null,
date: null
},
statusSelected: null,
otherDiets: false,
otherGasotherapies: false
})
}
export function selectDateInternacao(args){
modalDatetimepicker = new ModalDatetimepicker();
modalDatetimepicker
.pickDate({
title: "Selecione a data",
theme: "light"
})
.then(result => {
var date = `${result.day}/${result.month}/${result.year}`
main.bindingContext.form.hospitalizationDate = date
})
.catch(error => {
console.log(`Error: ${error}`);
});
}
console.log(main.bindingContext.form.hospitalizationDate)
值得记住的是,该值已更新,它在屏幕上不会更改,但是如果我输入Item
,该值将更新
答案 0 :(得分:1)
使用fromObject({...})
时,将仅监视即时属性的更改。 modalDatetimepicker
嵌套在form
内,因此form
上的任何更改只能触发UI的更新。您可以使用以下两种语法之一强制使用
分配一个新对象以形成
main.bindingContext.form = Object.assign({}, main.bindingContext.form, {
hospitalizationDate: date
});
(或)
通过触发属性更改事件来强制更改
main.bindingContext.form.hospitalizationDate = date;
main.bindingContext.notifyPropertyChange('form', main.bindingContext.form);