내가 '선택'이라는 모델 값 객체를보고 지침을 만들 것입니다. 이런 식으로 뭔가 :
<tr ng-repeat="element in body">
<td ng-repeat="h in header"
my-cell="selected"
row="{{$parent.$index}}"
col="{{$index}}"
style="width:{{element.width}}px">{{element[h.column]}}
</td>
</tr>
UPDATE
위의 솔루션 주변의 문제는 NG-반복 그렇게 $의 scope.select의 변화가없는 한에 각 $ 인덱스 항목에 대한 범위를 격리했다입니다 다른 세포들에 의해 보여진다. 나는 $이 방출과 $ 이벤트에 사용이 해결하기 위해,보고 : 솔루션을 koolunix..tried http://plnkr.co/edit/CS21gUe3arstrgubnpTr?p=preview
angular.module("CustomTable").directive("selectMe", function($rootScope) {
return ({
restrict: "A",
link: link,
require: "^customTable"
});
function link(scope, element, attributes, ctCtrl) {
var selected,
mkEvent = function(r,c) {
scope.$emit('selectMeEvent',{
row: r,
col: c
});
}
element.on('click', function(e) {
mkEvent(attributes.row,attributes.col);
});
$rootScope.$on('selectMeEvent',function(e,sObj) {
(sObj.row === attributes.row &&
sObj.col === attributes.col) ?
element.addClass('highlight-me') :
element.removeClass('highlight-me');
});
}
});
@ .. 나는 그것의 시계 부분이 예상대로 작동하지 않습니다 beliebe에 ..을 여기서 plnkr을보십시오. 지시어가 파일에 있습니다. selectMe.js http://plnkr.co/edit/yf7Ywfj9RjDuaDnOx6DL – runtimeZero
당신의 plunker 링크가 존재하지 않습니다. 정말로 저장 했습니까? – koolunix
절대적으로 .. 여기가 또있다 http://plnkr.co/edit/yf7Ywfj9RjDuaDnOx6DL?p=info – runtimeZero