9
지시문 안에 개인 함수를 만들 수 있습니까? 지시어 템플릿을 채우기 위해 지시문 내에서 다소 복잡한 프로세스를 수행해야합니다. 이 (HTML) 같은지시문 내 개인 함수 만들기
뭔가 :
<textarea the-result="data">
</textarea>
자바 스크립트 :
angular
.module("MyModule")
.directive("theResult", [function() {
return {
scope: {
theResult: "="
// calculatestuff = function(d){ // ... } can't put it here (error)
},
template: ' ... '
+ '{{calculatestuff(theResult.someproperties)}}'
+ ' ... '
}
}])
내가 calculatestuff
를 넣을 수 있습니다?
브라우저에서 최종 결과가 비어 있습니다. ( –
맞아요, 조금 피곤하네요. 내 대답을 편집했습니다 :). – Blackhole
함수를 링크 내의 범위로 이동 한 후 작동합니다. 감사! –