Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Proxies generated confusion #3132


User avatar
0
bilalhaidar created

Hi, In one of the AppServices, I am seeing the following code generated. So which code is being called? Because I noticed that one of them uses $http and the other uses abp.ajax to perform the code.

And from debugging, I noticed the Factory is being used. But why generated the other one?

Thanks

var serviceNamespace = abp.utils.createNamespace(abp, 'services.app.personofConcern');

    serviceNamespace.getPocs = function(input, ajaxParams) {
        return abp.ajax($.extend({
            url: abp.appPath + 'api/services/app/personofConcern/GetPocs',
            type: 'POST',
            data: JSON.stringify(input)
        }, ajaxParams));
    };

And,

(function (abp, angular) {

    if (!angular) {
        return;
    }
    
    var abpModule = angular.module('abp');
    
    abpModule.factory('abp.services.app.personofConcern', [
        '$http', function ($http) {
            return new function () {
                this.getPocs = function (input, httpParams) {
                    return $http(angular.extend({
                        url: abp.appPath + 'api/services/app/personofConcern/GetPocs',
                        method: 'POST',
                        data: JSON.stringify(input)
                    }, httpParams));
                };

4 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    When you inject a service to an angular controller, $http is called. You can also use abp.services.... syntax in angularjs, in that case the jquery version is called.

  • User Avatar
    0
    bilalhaidar created

    Why the 2 versions to support SPA and multi-page?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Yes, exactly that is the reason why we have two versions.

  • User Avatar
    0
    bilalhaidar created

    Thanks :)