この角度指示文では、これらのリスト項目にクリック機能をバインドしたいと思いますが、これを行う方法はわかりません... div、これらのすべてのリスト項目のクリックリスナを作成する方法...?AngularJS - 子要素にクリック機能をバインドするにはどうすればいいですか
app.directive('paginaLijst', function() {
return {
templateUrl: 'js/templates/paginas.html',
restrict: 'AE',
replace: true,
link: function($scope, element, attrs) {
element.bind('mouseenter', function() {
element.css('background-color', 'yellow');
});
element.bind('mouseleave', function() {
element.css('background-color', 'white');
});
}
};
});
と、このこのセレクタのテンプレート
<div ng-class="colSizeList" class="beheer a-show-hide" id="opdrachten" ng-hide="opdActive">
<h4>Beheer opdrachten</h4>
<ul class="list-group">
<li class='list-group-item opdracht' ng-class="{ 'active': $index == selectedIndex }" ng-repeat="opdracht in opdrachten">
<a href="#">
<span>{{opdracht.vak}}</span>
<small>{{opdracht.titel}}</small>
</a>
</li>
</ul>
</div>
私はホバリングしたくないけど、クリックすると...私はメインポストで言ったように。 –
http://stackoverflow.com/questions/27656721/bind-event-to-child-element-of-directive-in-link-function –
なぜあなたは単純なngを使用する代わりにリンク関数内でそれをしたいですか? - クリックしますか? – Groben