how to access property in a observable

老子叫甜甜 提交于 2019-12-24 14:22:19

问题


I want to access the property in 'selectedCeremonyToUpdate()' observable whose property name is in 'name'. If 'name' contains 'City' then i want

self.edit = function (data, event, name) {
alert("In " + self.selectedCeremonyToUpdate().City());
}

how to do this..


回答1:


You can access object properties by name using array semantics. Try this:

self.selectedCeremonyToUpdate()[name]()


来源:https://stackoverflow.com/questions/14055594/how-to-access-property-in-a-observable

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!