angular.js - controller获取service的值
世界只因有你
世界只因有你 2017-05-15 16:53:46
0
1
501
var sdApp = angular.module("sdApp", []);

//订单;
//服务;
sdApp.service("orderService", ["$http", function(a){
    var s = {
        searchData : function(data){
            a({
                method: "post",
                url: "/?app_act=/orders/ajax_order_list&app_fmt=json",
                data: $.param(data),
                headers: {"Content-Type":"application/x-www-form-urlencoded", "x-camnpr-uid":"1000"}
            }).success(function(res){
                console.log(res);
                return res;
            });
        }
    };
    return s;
}]);

//控制;
sdApp.controller("orderSearchCtrl", ["$scope", "$http", "orderService", function(a, b, c){
    //搜索;
    a.search = function(){
        a.res = c.searchData(a.orData);
        console.log(a.res);
    };
}]);

为什么console.log出来的a.res是undefined?

世界只因有你
世界只因有你

membalas semua(1)
黄舟

searchData() tidak mempunyai nilai pulangan return, lalainya ialah undefined

Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan