1
私はAngularJSが初めてです。これは私の最初のプランカです。divをAngularJSのインデックスでクラス別に参照する方法は?
ユーザーがセクション内のリンクをクリックすると、リンクの値が結果に表示されるようにしようとしています。他の2つの結果は、それらの値をクリアする必要があります。
インデックス内のクラス内の特定のアイテムを参照する方法に関するドキュメントは見つかりません。 jQueryのでは、私は通常、ここで
// get this index of the thing that was clicked
$this = $(this),
Idx = $BUTTONS.BigButtons.index($this),
ThisButton.eq(Idx).doSomething();
<body ng-controller="MainController as main">
<div class="title" ng-repeat="i in [1,2,3]">
<p>This is section {{i}}</p>
<ul>
<li ng-repeat="j in [1,2,3]">
<a href="" ng-click="main.displayContent(i, j)">section {{i}} - link {{j}}</a></li>
</ul>
<div class="results" ng-bind="main.results"></div>
</div>
</body>
var app = angular.module('controllerAsDemo', []);
app.controller('MainController', function() {
this.results = "Lame default";
this.displayContent = function(firstIdx, secondIdx) {
this.results = "populate section "
+ firstIdx
+ " with the number "
+ secondIdx
+ " - other two results should be empty"
;
};
});
は、私はあなたが望むものを達成するためのクラスを見てすべきではないと思います
Demo
恐ろしい!!!私はあなたが提供したもののような例は見ていません。それは私が必要とするものを正確に行うようです。本当にありがとう!!! –
ようこそ。 Angularがあなたのためにdom操作をすることを覚えておいてください。あなたが何かをするためにDOMを操作する必要があるなら、あなたは何か間違っているかもしれません。 – Alok