0
ここに私のHTMLコードが入ります。子ディレクティブに基づいてDOMを操作する属性 - angularJs
<parent>
<div idx=2>DIV - 3</div>
<div idx=0>DIV - 1</div>
<div idx=1>DIV - 2</div>
</parent>
ディレクティブの属性に基づいて子divを並べ替える必要があります。ここで私のangularjsコードに行く。 idx
の値に基づいて、私はDOMを操作したい。
app.directive('parent', function() {
return {
restrict: 'E'
}
});
app.directive('idx', function() {
function link(scope, element, attrs) {
console.log(scope.idx);
}
return {
restrict: 'A',
scope: {
idx: '='
},
link: link
}
});
私はangularjsを初めて利用しています。私を助けてください、またはこれを達成するためのヒントを提供してください。