我用meanjs发生器获得此代码
mycode的: - 从servercontroller查询的数据。但我需要使用HTTP请求以从API服务器的数据。所以我尝试类似代码以http继
SuperherosController.js
angular.module('superheros').controller('SuperherosController', ['$scope','$http', '$stateParams', '$location', 'Authentication', 'Superheros',
function($scope, $stateParams, $location, Authentication, Superheros,$http) {
$scope.authentication = Authentication;
// *Find a list of Superheros*
$scope.find = function() {
//Actual code with out Http request
// $scope.superheros = Superheros.query();
/// *The code i tried with Http and injected dependencies*
//行56:13 $ http.get( 'http://api.xxx.com/superheros').success(功能(数据){ $ scope.superheros = data; }); }; } ]);
**通过上述修改http.get做出请求,但有一个错误认识: -
错误**
$http.get(...).success is not a function [email protected]http://localhost:3000/modules/superheros/controllers/superheros.client.controller.js:56:13
错误:[$资源:badcfg]错误的资源配置。预期的响应包含一个对象,但得到了一个数组与一些参考角域
请问我知道我的代码中有什么问题..或者我该如何解决这个问题? 感谢您的帮助提前!
是的,我有我的错...谢谢哈雷什! – Prasad 2015-03-04 06:20:57