得到错误:[$ injector:unpr]未知的提供者

时间:2015-03-17 02:54:44

标签: angularjs

工厂

angular.module('SearchApp')
    .factory('queryFactory', ['$http', function($http) {

var urlBase = 'http://localhost:9002/v1/search?rs:q=oil';
var queryFactory = {};
queryFactory.getQueryResults = function () {
    $http.defaults.headers.common['Authorization']  = 'Basic' + btoa('admin' + ':' + 'admin');
    return $http.get(urlBase + '&rs:searchCategory=allegro');
};

控制器

angular.module('SearchApp')
    app.controller('SearchResultsController', ['$scope', 'queryFactory', function ($scope, queryFactory) {
    $scope.status;
    $scope.searchResults;
    getQueryResults();

function getQueryResults() {
    queryFactory.getQueryResults()
        .success(function (data) {
            $scope.searchResults = data;
        })
        .error(function (error) {
            $scope.status = 'Unable to load search results: ' + error.message;
        });
}
}]);

0 个答案:

没有答案