我有由ng:repeat创建的html元素.我需要在所有其他元素的ng-click中更改"active"类,并且需要在事件发生的特定元素中添加类.
<ul class="paginate">
<li ng-repeat="value in pageList">
<a ng-class="{active : $first, item : true}" ng-click="clickedPage(value)">{{value}}</a>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
这里首先<a>有'活跃'课程.我需要删除'active'类,<a>如果我点击<a>没有'active'类,则需要添加相同的类.
我有java类,将调用字符串替换的递归方法.该方法将在逐个替换所有必需字符后返回字符串.但这不符合预期.请在下面找到代码.
public class TestingRecursion {
private static String startRecursion(String value){
value = value.replaceFirst("a", "b");
if(value.contains("a"))
startRecursion(value);
return value;
}
public static void main(String[] args) {
String value = "1a 2a 3a 4a";
String afterRecursion = startRecursion(value);
System.out.println(afterRecursion);
}
}
Run Code Online (Sandbox Code Playgroud)
预期输出 - "1b 2b 3b 4b"实际输出 - "1b 2a 3a 4a".