本文整理汇总了TypeScript中forms/form.Form.valueFor方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Form.valueFor方法的具体用法?TypeScript Form.valueFor怎么用?TypeScript Form.valueFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms/form.Form
的用法示例。
在下文中一共展示了Form.valueFor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: actionHandler
function actionHandler (req: express.Request, res: express.Response, next: express.NextFunction): void {
function extractPropertyName (action: object): string {
return Object.keys(action)[0]
}
if (req.body.action) {
const actionName = extractPropertyName(req.body.action)
const form: Form<MonthlyIncome> = req.body
switch (actionName) {
case 'addOtherIncomeSource':
form.model.addEmptyOtherIncome()
break
case 'removeOtherIncomeSource':
const selectedForRemoval: IncomeSource = form.valueFor(extractPropertyName(req.body.action[actionName]))
form.model.removeOtherIncome(selectedForRemoval)
break
case 'resetIncomeSource':
const propertyName = extractPropertyName(req.body.action[actionName])
const selectedForReset: IncomeSource = form.valueFor(propertyName)
form.model.resetIncome(propertyName, selectedForReset)
break
}
return renderView(form, res)
}
next()
}
示例2: actionHandler
function actionHandler (req: express.Request, res: express.Response, next: express.NextFunction): void {
function extractPropertyName (action: object): string {
return Object.keys(action)[0]
}
if (req.body.action) {
const actionName = extractPropertyName(req.body.action)
const form: Form<PriorityDebt> = req.body
switch (actionName) {
case 'resetDebt':
const propertyName = extractPropertyName(req.body.action[actionName])
const selectedForReset: ExpenseSource = form.valueFor(propertyName)
form.model.resetIncome(propertyName, selectedForReset)
break
}
return renderView(form, res)
}
next()
}
示例3: it
it('should return undefined if value associated with given field does not exist', () => {
const form: Form<any> = new Form({})
expect(form.valueFor('address[city]')).to.equal(undefined)
})