即将从这个框架中前进,我不想这样做,因为它看起来很棒,但在我的早期阶段却面临着一个又一个的头痛。
目前,我的问题是试图从控制器发出一个$http调用。以下是我的当前代码:
angular
.module('login', [])
.controller('LoginController', ['$scope', '$http', 'supersonic', function($scope, $http, supersonic) {
// Controller functionality here
$scope.login = function () {
supersonic.logger.debug('before ajax');
$http.post('http://server/api/user/login', {
username: $('#username').val(),
password: $('#password').val()
}).error(function () {
console.log('error');
supersonic.logger.debug('Error');
}).success(function () {
console.log('success');
supersonic.logger.debug('Success');
});
supersonic.logger.debug('after ajax');
}
}]);我承认我对此很陌生,但我读过很多文档,并在互联网上尝试了不同的方式注入$http等,但没有任何运气。此代码将导致错误“未知提供者: supersonicProvider”。
如果我把超音速排除在注入之外,那么超声速参数是不确定的。
即使我不包括超声速注入并注释掉supersonic.logger行,$http行也会生成"$不是定义“的错误。
如果这有任何区别的话,通过usb从chrome调试器获取这些错误。
感谢你对这件事的任何帮助。
发布于 2015-04-01 07:38:03
下面的代码似乎很有用,让我可以访问控制器中的$http和超音速
angular
.module('login', ['supersonic'])
.controller('LoginController', function($scope, supersonic, $http) {
});https://stackoverflow.com/questions/29357798
复制相似问题