私は項目のリストを生成するためにng-repeatを使用しています。ユーザーが上のWebページ上の特別なマーカーをクリックすると、次の関数は対応するアイテムまでスクロールするイベントを受け取ります。スクロールするだけでなく、ユーザーがマウスを再び動かすまで、アイテムを強調表示したいと思います。私の問題は、このことです。私は、ng-repeatリストの1つの要素のCSSクラスを操作する必要があります。私はすべてのng-repeat要素が独自のローカルスコープを取得するため、可能性があると考えましたが、解決策が見つかりません。私のディレクティブの
パート:
//if a marker is clicked, the following code should bring the user to the corresponding item
$rootScope.$on("Scroll_to_product", function (event, args) {
product.gotoElement(args);
});
/*function which takes the class id of an html element as argument and brings
the user to the corresponding product*/
product.gotoElement = function (args) {
var elementID = 'product-' + args;
$location.hash(elementID);
// call $anchorScroll()
$anchorScroll();
}
すべてのヘルプは素晴らしいことだ、Hucho
関連する問題ですhttps://stackoverflow.com/questions/19331779/how-to-highlight-a-selected-row-in-ngrepeat – Tuure