注入$ scope和$ http会引发错误

时间:2014-09-30 09:36:48

标签: angularjs

我刚刚写道:

var app = angular.module('app', []);
app.controller('SearchController', [ '$scope, $http', function( $scope, $http ) {
}]);

...我收到以下错误:

Error: [$injector:unpr] http://errors.angularjs.org/1.3.0-rc.3/$injector/unpr?p0=%24scope%2C%20%24httpProvider%20%3C-%20%24scope%2C%20%24http Q/<@http://welcomepage.local/vendor/angularjs-1.3.min.js:6:414

我只是关注官方文档的例子,你能告诉我哪里错了吗? 我使用v 1.3.0-rc.3

2 个答案:

答案 0 :(得分:1)

当然我有html:

<html ng-app="app">
    <body>
        <div ng-controller="SearchController">[...]

答案 1 :(得分:1)

app.controller('SearchController', [ '$scope', '$http', function( $scope, $http ) { // you missed '' here 
 }]);

//您必须注入依赖项[ '$scope', '$http', functi..,请注意$http$scope位于"'