jquery - Angular js how to call service in controller.
某草草
某草草 2017-05-15 16:59:41
0
1
574
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?

某草草
某草草

reply all(1)
PHPzhong

This link was written by a person 2 years ago, it is very detailed

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template