我想获取数据来更新我的表达式{{myList}},但似乎我的服务中存在$ scope问题,下面的代码似乎不起作用:
app.controller('AppCtrl', ['$scope', 'getTopicContent', function($scope,getTopicContent){
getTopicContent.request();
}]);
app.factory('getTopicContent', ['$http', function($http, $scope){
var query = function() {
return $http({
url: "http://www.corsproxy.com/mydata.me/level1/list.php",
method: "GET"
}).success(function(data, $scope){
$scope.myList= data;
});
}
return {
request : function(){
return query();
}
}
}]);
但是,如果我这样做,它会工作,我运行。 success
而不是我的服务。
变化'应用。工厂('getTopicContent',['$ http','$ scope',函数($ http,$ scope)' – RandomUser 2014-12-05 03:07:32
@RandomUser我在它不工作之前试过了,它表示Unknown provider:$ scopeProvider < - $ scope < - getTopicContent – mike19911 2014-12-05 03:17:27