0
나는 녹아웃을 사용하여 문제를 해결하려고하고 있습니다. 템플릿을 사용하여 내가보기에 더 깨끗하게 작업하고 싶습니다. 그러나 지금은 함수에서 인수로 사용해야하는 템플릿에 추가 매개 변수를 전달해야하기 때문에 만들 수 없습니다. 지금까지는 그렇게 할 수있는 방법을 찾지 못했습니다. 녹아웃 3.2.0 - 템플릿 내에서 추가 매개 변수 전달
<script type="text/html" id="my-template">
<div data-bind="click: $root.selectItem.bind($data,$data.type)">
</script>
<div data-bind="template:{name:'my-template',foreach: contactInfo().Children, data:{type:'firstContactList'}"></div>
<div data-bind="template:{name:'my-template',foreach: contactInfo().Children, data:{type:'SecondContactList'}"></div>
그래서 기본적으로 내가 원하는 것은 내 템플릿으로 foreach 문을 사용하고 있으므로,
firstContactList
또는
SecondContactList
같은 문자열을 추가 매개 변수를 전달 할 수있을 것입니다 : 여기
내가 만든 템플릿입니다.
지금까지 ...
이것은 도움이 될 수 있습니다 : http://stackoverflow.com/questions/20430976/can-i-pass-a-variable-in-a-template-binding – Rajesh
'firstContactList'와'SecondContactList'의 차이점은 무엇입니까? – Tomalak
firstContactList 또는 SecondContactList (그냥 문자열)를 매개 변수로 전달해야합니다. 왜냐하면 값에 따라 selectItem 메서드 내에서 수행하는 작업이 다르기 때문입니다. 난 그냥 parameter === firstContactList -> 그런 다음 otherwhise, 이렇게 할 수있는 매개 변수에 대한 vertification 있습니다 ... 희망 그것은 분명하다. – Azuk