我的表格非常简单:
data1 <- function(n,ns,alpha,covmat=NULL){
tmp <- .Fortran("data",
n = as.integer(n),ns= as.integer(ns)
alpha=as.numeric(alpha),covmat=as.vector(covmat),
x=as.double(rep(0,n)),y=as.double(rep(0,n)))
)
}
result <- list(x=tmp$x, y=tmp$y)
return(result)
}
但是当切换排序时,这会产生<form>
<label><input type="radio" name="sortby" value="created" checked ng-model="sortby"> By creation date</label>
<label><input type="radio" name="sortby" value="text" ng-model="sortby"> By text</label>
</form>
<div ng-repeat="todo in TodoList.getTodos() | orderBy: sortby">
<h1>{{ todo.text }}</h1>
</div>
。如何使这个开关工作?
答案 0 :(得分:1)
看起来你的TodoList.getTodos()函数每次调用时都会生成一个新数组,这个常见错误在https://docs.angularjs.org/error/ $ rootScope / infdig中解释。解决方案是将todoList保存在变量中,只有在更改列表时才应更新,并且TodoList.getTodos()函数只返回此变量:
// should be updated only when the list is changed
var todoList= [ YOUR TODO LIST ];
TodoList.getTodos = function() {
return todoList;
};