hoemApp.controller('homeController', ['$http', '$scope', '$interval', 'homecharts', function ($http, $scope, $interval, homecharts) {
// controller 内容 , 怎么调用 service
}]).service('homecharts', ['$http', '$rootScope', '$interval', function ($http, $scope, $interval) {
$http({
method: 'GET',
params: {username: "admin"},
url: 'http://localhost:9090/homevm'
}).success(function (data, status, headers, config) {
$scope.infoData = data;
}).error(function (data, status, headers, config) {
});
My service here does not need to return any data. All data assignments are completed in the service.
Now I want to use routeProvider to realize the display of ng-view.
But routeProvider.when( ) method specifies a controller, but my current controller does not call the service.
How should I call the service in the controller?
This link was written by a person 2 years ago, it is very detailed