2016-04-10 21 views
0

私はMetronicアプリケーションで角度サービスを使用しようとしています。私はこのように私のサービスを指定している:私は、ページを実行すると、私はMetronicApp角度サービス

http://errors.angularjs.org/1.4.7/$injector/unpr?p0=httpProvider%20%3C-%20http%20%3C. 

これは、ように見える得る、しかし

angular.module('MetronicApp').controller('ShapersController', ['shaperService', function (shaperService, $rootScope, $scope, $timeout) { 
$scope.$on('$viewContentLoaded', function() { 
    App.initAjax(); // initialize core components 
    Layout.setSidebarMenuActiveLink('set', $('#sidebar_menu_link_profile')); 
    $scope.shaper = shaperService.shapers; 
    $scope.fname = "Jason";// set profile link active in sidebar menu 
    $scope.lname = "Kane";// set profile link active in sidebar menu 
    $scope.name = $scope.fname + " " + $scope.lname;// set profile link active in sidebar menu 
}); 

// set sidebar closed and body solid layout mode 
$rootScope.settings.layout.pageBodySolid = true; 
$rootScope.settings.layout.pageSidebarClosed = true; 
}]); 

:ここ


angular.module('MetronicApp').service('shaperService', ['$http', function ($http) { 
this.shapers = function(params) 
{ 
    return $http.get('http://serviceurl.app', { 
     params : params 
    }); 
} 
}]); 
は私のコントローラであり、噴射誤差である。私の質問は、私のコントローラに私のサービスを注入するにはどうすればいいですか?

ありがとうございました

+0

悪い入力、 'http'は、あなたのサービスの最初の行である 'http http'です。 –

+0

ここで問題はありません。その構文は不平を言っていません。 –

+1

'http http'を' $ http'に変更しましたか?それは角度マークが付いたエラーです。 –

答えて

0

私は答えを見つけました。サービスは開始されませんでした。このようなサービスを開始することができます。

angular.module('MetronicApp').factory('shaperService', ['$http', function ($http) { 
this.shapers = function(params) 
{ 
    return $http.get('http://serviceurl.app', { 
    params : params 
    }); 
} 
}]);