将数据从服务传递到控制器

时间:2015-05-07 22:14:37

标签: angularjs service controllers

这是我的代码

temp <- lapply(x, function(x)grepl('[^0-9]',x))

temp
#> $a
#> [1] FALSE FALSE  TRUE
#> 
#> $b
#> [1] FALSE  TRUE FALSE
#> 
#> $c
#> [1] FALSE  TRUE  TRUE

# applies the or operator (|) across all the arguments
OR <- function (...) 
{
    argList <- list(...)
    names(argList) <- NULL
    switch(as.character(length(argList)),
           `0` = NULL, 
           `1` = argList[[1]], 
           `2` = argList[[1]] | argList[[2]],
           do.call("OR", c(list(argList[[1]] | argList[[2]]), 
                            argList[-(1:2)])))
}

x_clean  <-  x[!do.call(OR,temp),]

我需要知道如何将数据从服务正确传递到控制器,以便使用指令标记显示

我知道该指令有效,我知道服务有效,但控制器似乎正在接收数据

http://embed.plnkr.co/Pdt6GK/preview - 链接到我的插件

一如既往地谢谢

1 个答案:

答案 0 :(得分:0)

您服务的语法错误,因为它应该是factory

此外,如果您希望能够使用控制器中的studentData.success,那么您只需从工厂返回$http承诺:

app.factory('studentData', ['$http',function($http){
  return $http.get('http://purplenimbus.net/edu/students.php');
}]);
相关问题