更新时间:2023-02-27 08:19:47
最简单的选择是将一个对象传递给模板绑定,该模板绑定允许您访问实际的可观察对象,例如:
The simplest choice is to pass an object to the template binding that allows you to access the actual observable like:
template: { name: 'text', data: {field: name} }
然后,在模板中绑定字段"而不是"$ data".
Then, bind against "field" instead of "$data" in your template.
要考虑的另一件事是使用函数确定模板,然后可以使用单独的模板进行编辑/查看,例如:
http://www.knockmeout.net/2011/03/quick-tip-dynamically- changes.html
Another thing to consider would be using a function to determine your template, then you can use separate templates for edit/view like:
http://www.knockmeout.net/2011/03/quick-tip-dynamically-changing.html