0
我得到这个错误服务未能注入控制器
参数 'AppCtrl' 不是一个函数,得到了如下
我app.js字符串:
var App = angular.module('App', ['ionic']);
App.service("FreshlyPressed", ["$http","$log",FreshlyPressed]);
App.controller("AppCtrl", "FreshlyPressed", ["$scope", "$log", AppCtrl]);
function AppCtrl($scope, FreshlyPressed, $log){
$scope.refresh = function(){
FreshlyPressed.getBlogs();
}
}
function FreshlyPressed($http, $log){
this.getBlogs = function(){
$http.jsonp("https://public-api.wordpress.com/rest/v1/freshly-pressed?callback=JSON_CALLBACK")
.success(function(result){
$log.info(JSON.stringify(result.posts));
});
}
}
不知道我错了哪里,我已经FreshlyPressed作为参数进入AppCtrl函数。
哎呀我搞砸了。但是param的顺序在控制器功能中真的很重要吗? – 2014-11-24 04:57:53
不,但它应该很容易处理,当使用更多的参数:) – jamseernj 2014-11-24 04:59:29
看看这个与第一个答案它将是有用的 http://stackoverflow.com/questions/19238191/understanding-angular-js-controller-parameters – jamseernj 2014-11-24 05:03:33