‫۱۰ سال و ۴ ماه قبل، چهارشنبه ۱۴ خرداد ۱۳۹۳، ساعت ۲۳:۵۸
//define
app.service('objUser', function ($http) {  

    this.user = [{
        id: null,
        firstName: null,
        lastName: null,
        email: null
    }];

  this.userList = function () {
        var promise = $http.get('api/user')
            .success(function (res) {
                return res;
            });
        return promise;
    };
});

//call
app.controller('UserListCtrl', function ($scope, objUser) {
    $scope.user = objUser.user;
    objUser.userList().then(function (promise) {
        $scope.user = promise.data;
    });
});