의 상태에 따라 달라 한마디로AngularJS와 DOM 요소는 내가이 간단한 지침을 가지고 지침
app.directive('participants',function(){
return{
restrict:'E',
scope:{
allParticipants:"=",
appendOption:"="
},
templateUrl:'/templates/participants.html',
link: function(scope,element,attr){
scope.$watch('allParticipants',function(value){
if (value){
value.length > 3 ? showShortParticipants() : showFullParticipants()
}
});
}
}
});
을 - 나는 다른 아이의 DOM 요소가 value
에 따라 작성하고 싶습니다. 예를 들어, value.length
이 3보다 크면 유형 1의 요소를 만들고 유형 2의 요소를 만들지 않으려면 1과 다른 템플릿을 만듭니다.
그 우아한 방법은 무엇입니까?
는
그리고 어떤 유형의 가능성이 있습니까? 다른 입력 유형? 또는 데이터를 표시하는 다른 방법? 또는...? –
Im은 다른 자식 템플릿을 만들 때, 범위의 결과에 따라 달라집니다 :) – Chenko47
"fullParticipants"뷰에서만 표시되어야하는 요소에 템플릿의'ng-if = "allParticipants.length> 3"'을 사용하면됩니까? – dex