2
두 개의 지시문이 있으며 각각 ng-repeat
의 결과로 하나씩 선택하고 싶습니다.지시어를 Angular에서 동적으로 선택
<div class="{{field.type_desc}}" ng-repeat="field in row.fields"></div>
는이 컨트롤러 I는 HTML 올바른 클래스에서 볼 수있는 페이지로드 후
app.directive('Textbox', function($compile) {
return {
restrict: 'C',
link : function (scope,element)
{
formFieldTemplate= $('<input>').attr('type','password');
$compile(formFieldTemplate)(scope);
var formListElement = $(element);
formListElement.append(formFieldTemplate);
}
}
})
의 코드이지만, 여전히 나는 지시어를 볼 수 없습니다.
당신은 지시의 동적 생성을위한 몇 가지 누락 당신의 도움이
이 하나가 나를 놀라게했다. 나는 또한 ng-class의 변형으로 시도했지만 어느 것도 작동하지 않았다. – Sharondio
ng-repeat가 터미널이고 우선 순위가 1000 인 것과 관련이 있다고 생각했지만 기본적으로 우선 순위는 0입니다. 즉, ng-repeat가 먼저 실행되고 컴파일 프로세스 (터미널)가 중단되므로 지시문이 트리거되지 않아야합니다. 나는 그것을 시도했지만 작동하지 않습니다 http://plnkr.co/edit/IRFLfQKRcp1kxuvhGNdE?p=preview –
이것 좀보세요 : http://stackoverflow.com/questions/14425497/angularjs-ngrepeat-with-multiple -object-types/14425547 # 14425547 –