简体   繁体   中英

passing multiple values to use anchorscroll

<div class="slideHeading" id="slide-{{$index}}" ng-click="scrollTo('slide-'index)">

Probably a really easy question but how can I pass through slide-{{$index}} for the parameter scrollTo? It works fine if it's set to id='{{$index}}' and scrollTo(index) but i want to add the slide- to it as well

scope.widget.scrollTo = function(id) {
$location.hash(id);
$anchorScroll();
};

您需要在ng-click使用字符串连接

ng-click="scrollTo('slide-' + $index)"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM