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的新手。請幫助我,或者只是提供一些提示來實現這一點。