私はこれを数時間研究してきました。
$('#bottom .downloads .links a').click..... の jQuery セレクターがあるとします。
Angular ディレクティブで同じタイプのことを行うにはどうすればよいですか?
これは私がこれまでに持っていたものであり、機能しますが、ページ上のすべてのタグに対して.
angular.module('directives', []).directive('a', function(mongoDB){ //Don't need ['customServices'], it can just be [] to use mongoDB
return {
restrict : 'E',
link : function(scope, element, attrs){
element.on('click', function(){
//But this gets called for all links on the page
//I just want it to be links within the #bottom .downloads .links div
//I wanted to use a directive instead of ng-click="someMethod()"
});
}
});
このディレクティブを特定の div のみをターゲットにする方法はありますか? 制限を 'C' または 'A' に変更して、リンクに属性を追加できると思いますが、現在 jQuery セレクターで慣れているようにフロント エンドをレイアウトできるかどうか疑問に思っていました。