angular.js - controller gets the value of service
世界只因有你
世界只因有你 2017-05-15 16:53:46
0
1
513
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);
    };
}]);

Why is the a.res output from console.log undefined?

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

reply all(1)
黄舟

searchData()没有return一个返回值,默认就是undefined

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