Base solution for your next web application
Open Closed

are angular services autogenerated? #113


User avatar
0
cicciottino created

i'm trying to ad a new entity to the SimpleTaskSystem example project

in order to add a "car" entity and everything it needs to be displayed i did exactly this till now:

  1. create the "car" entity
  2. create the a new repositoty for the new entity
  3. create the ApplicationLayer a dn relative DTOs + input/output objects
  4. create views and relative angulars'controller file

at this poin i got this error into the browser consolle:

Error: [$injector:unpr] http://errors.angularjs.org/1.3.8/$injector/unpr?p0=abp.services.tasksystem.carProvider%20%3C-%20abp.services.tasksystem.car%20%3C-%20sts.views.car.list
   at Anonymous function (http://localhost:6247/Scripts/angular.min.js:38:301)

i suppose the problem is the name of the angular services that i used in my angular controller (in my case 'abp.services.tasksystem.car') the question is:

  • is this angular service autogenerated?
  • is the naming convention (that i used) correct supposing that i have an ApplicationLayer that is named "CarAppServices" and has a method named "GetFreeCarsOutput"
  • did i miss something after the point "4"? did i have to add something else other than view and controller?

THE APPLICATION LAYER

public class CarAppServices : ApplicationService, ICarAppServices
    {
        private readonly ICarRepository _carRepository;
        private readonly IRepository<Person> _personRepository;

        public CarAppServices(ICarRepository carRepository, IRepository<Person> personRepository)
        { 
            _carRepository = carRepository;
            _personRepository = personRepository;
        }

        public GetFreeCarsOutput GetFreeCars(GetFreeCarsInput input)
        {
            var cars = _carRepository.GetAllFreeCars(input.MaxSpeed);
            return new GetFreeCarsOutput
            {
                Cars = Mapper.Map<List<CarDto>>(cars)
            };
        }
    }

THE ANGULAR CONTROLLER

(function() {
    var app = angular.module('app');

    var controllerId = 'sts.views.car.list';
    app.controller(controllerId, [
        '$scope', 'abp.services.tasksystem.car',
        function($scope, carService) {
            var vm = this;
	    .....
            ....
            ...
            ..
            .
		
	    var myCars = carService.getAllFreeCars({
	    .....
            ....
            ...
            ..
            .

18 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    Try renaming ICarAppServices to ICarAppService and CarAppServices to CarAppService. From the documentation (<a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Dynamic-Web-API">http://www.aspnetboilerplate.com/Pages/ ... ic-Web-API</a>):

    "To calculate service name: Service and AppService postfixes and I prefix is removed (for interfaces). Also, service name is converted to camel case."

    You can see all generated services by this URL: ~/api/AbpServiceProxies/GetAll?type=angular

  • User Avatar
    0
    abu created

    i also have same error i have an ImemberprofileAppService interface and memberProfileAppService class files

    the above two files present in application in MemberProfiles folder

    i used this in .js file

    abp.services.tasksystem.memberprofile

    i have the following coding in webapi

    DynamicApiControllerBuilder .ForAll<IApplicationService>(Assembly.GetAssembly(typeof(MYVEOApplicationModule)), "tasksystem") .Build();

    what is the service name in this case please give an answer....???? please

  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    Have you open the URL .../api/AbpServiceProxies/GetAll ? You can see names of your services here.

  • User Avatar
    0
    abu created

    sir i have use this script in my html page..!! but same problem..

    <script src="/api/AbpServiceProxies/GetAll" type="text/javascript"></script> and <script src="/api/AbpServiceProxies/Get?name=tasksystem/task" type="text/javascript"></script>

  • User Avatar
    0
    abu created

    sir i had send you all my coding part to you in your first to learn forum article please help me out sir

  • User Avatar
    0
    abu created

    ImemberprofileAppService code

    namespace MYVEO.MemberProfiles
    {
       public interface ImemberprofileAppService:IApplicationService
        {
            GetTasksOutput GetTasks(GetTasksInput input);
            void UpdateTask(UpdateTaskInput input);
            void CreateTask(CreateTaskInput input);
        }
    }
    

    memberprofileAppService code

    namespace MYVEO.MemberProfiles
    {
        public class memberprofileAppService : ApplicationService, ImemberprofileAppService
        {
             private ImemberprofileRepository _taskRepository;
           
            
            /// <summary>
            ///In constructor, we can get needed classes/interfaces.
            ///They are sent here by dependency injection system automatically.
            /// </summary>
            public memberprofileAppService(ImemberprofileRepository taskRepository)
            {
                _taskRepository = taskRepository;
                
            }
            
            public GetTasksOutput GetTasks(GetTasksInput input)
            {
                //Called specific GetAllWithPeople method of task repository.
                var tasks = _taskRepository.memberGetAll();
    
                //Used AutoMapper to automatically convert List<Task> to List<TaskDto>.
                return new GetTasksOutput
                       {
                           //Tasks = Mapper.Map<List<MemberProfilesDtos>>(tasks)
                       };
            }
            
            public void UpdateTask(UpdateTaskInput input)
            {
               
            }
    
            public void CreateTask(CreateTaskInput input)
            {
               
               // Logger.Info("Creating a task for input: " + input);
                var tasks = new memberprofile
                {
                    MemberCode=input.MemberCode,
                    Firstname=input.Firstname,
                    Lastname=input.Lastname,
                    MiddleInitial=input.MiddleInitial,
                    Additional=input.MiddleInitial,
                    DOB=input.DOB,
                    Email=input.Email,
                    PhoneNo=input.PhoneNo,
                    Extension=input.Extension
                };
                _taskRepository.Insert(tasks);
            }
        }
    

    Coding in webapi

    DynamicApiControllerBuilder
                   .ForAll<IApplicationService>(Assembly.GetAssembly(typeof(MYVEOApplicationModule)), "tasksystem")
                   .Build();
    

    Javascript code

    (function () {
        var app = angular.module('app');
        var controllerId = 'insertcontroller';
        app.controller(controllerId, [
            '$scope', '$location', 'abp.services.tasksystem.memberprofile',
            function ($scope, $location,memberprofileService) {
                var vm = this;
    
                vm.tasks = {
                    Membercode:'',
                    FirstName:'',
                    Lastname:'',
                    MiddleInitial:'',
                    Additional:'',
                    DOB:null,
                    Email:'',
                    PhoneNo:'',
                    Extension:''
                };
    
                var localize = abp.localization.getSource('MYVEO');
                vm.saveTask = function() {
                    abp.ui.setBusy(
                        null,
                        memberprofileService.createTask(
                            vm.tasks
                        ).success(function() {
                            //abp.notify.info(abp.utils.formatString(localize("TaskCreatedMessage"), vm.task.description));
                            $location.path('/');
                        })
                    );
                };
            }
        ]);
    })();
    

    html page coding

    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
    </head>
    
    <body>
        <div class="container" style="margin-bottom:4px; border:5px outset; border-color:#e1e1e1" ng-controller="insertcontroller as vm">
            <div class="col-md-12">
    
                <div class="profile_bg">
                    <h4 style="font-size:larger"><b>Member Profile</b></h4>
                    <div class="col-md-12">
                        <div class="col-md-5">
                            <span>MemberCode*</span>
                        </div>
                        <div class="col-md-5">
                            <input id="txtMemberCode" type="text" ng-model="vm.tasks.Membercode" />
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="col-md-5">
                            <span>First Name *</span>
                        </div>
                        <div class="col-md-5">
                            <input id="txtFirstName" type="text" ng-model="vm.tasks.FirstName" />
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="col-md-5">
                            <span>Last Name</span>
                        </div>
                        <div class="col-md-5">
                            <input id="txtLastName" type="text" ng-model="vm.tasks.Lastname" />
                        </div>
                    </div>
    
                    <div class="col-md-12">
                        <div class="col-md-5">
                            <span>Middle Initial</span>
                        </div>
                        <div class="col-md-5">
                            <input id="txtMiddle" type="text" ng-model="vm.tasks.MiddleInitial" />
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="col-md-5">
                            <span>Additional</span>
                        </div>
                        <div class="col-md-5">
                            <textarea id="TextArea1" rows="2" cols="20" ng-model="vm.tasks.Additional"></textarea>
                        </div>
                    </div>
    
                    <div class="col-md-12">
                        <div class="col-md-5">
                            <span>Date Of Birth*</span>
                        </div>
                        <div class="col-md-5">
                            <input id="txtDOB" type="text" ng-model="vm.tasks.DOB" />
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="col-md-5">
                            <span>Email *</span>
                        </div>
                        <div class="col-md-5">
                            <input id="txtEmail" type="text" ng-model="vm.tasks.Email" />
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="col-md-5">
                            <span>Contact Number*<span style="color: #00629F">(Ex-987-666-4323)</span></span>
    
                        </div>
                        <div class="col-md-5">
                            <input id="txtContactNo" type="text" maxlength="12" ng-model="vm.tasks.PhoneNo" />
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="col-md-5">
                            <span>Extension</span>
                        </div>
                        <div class="col-md-5">
                            <input id="Text1" type="text" ng-model="vm.tasks.Extension" />
    
                        </div>
                    </div>
                    <div class="col-md-12">
                    </div>
                    <div class="col-md-5">
                    </div>
                    <button ng-click="vm.saveTask()"type="submit">INSERT</button>
                </div>
            </div>
        </div>
        <script src="/api/AbpServiceProxies/GetAll" type="text/javascript"></script>
        <script src="/api/AbpServiceProxies/Get?name=tasksystem/task" type="text/javascript"></script>
    </body>
    </html>
    

    error

    Error: [$injector:unpr] http://errors.angularjs.org/1.3.15/$injector/unpr?p0=abp.services.tasksystem.memberprofileProvider%20%3C-%20abp.services.tasksystem.memberprofile%20%3C-                   0nsertcontroller
    

    please help me out sir waiting for reply thank you

  • User Avatar
    0
    hikalkan created
    Support Team

    OK, but please just open .../api/AbpServiceProxies/GetAll?type=angular in your browser and paste the contents here.

    It will be similar like that: <a class="postlink" href="http://qasample.aspnetboilerplate.com/api/AbpServiceProxies/GetAll?type=angular">http://qasample.aspnetboilerplate.com/a ... pe=angular</a>

  • User Avatar
    0
    abu created

    sir after opening following link in my browser its blank page...??? now what the next step to work it out..???

    <a class="postlink" href="http://localhost:6234/api/AbpServiceProxies/GetAll?type=angular">http://localhost:6234/api/AbpServicePro ... pe=angular</a>

    please reply thank you

  • User Avatar
    0
    hikalkan created
    Support Team

    That's strange.. Can you debug to see if this code is called:

    DynamicApiControllerBuilder .ForAll<IApplicationService>(Assembly.GetAssembly(typeof(MYVEOApplicationModule)), "tasksystem") .Build();

    ??? How did you created your project? With the templates?

  • User Avatar
    0
    abu created

    yes sir i have created project with template and also check by debug the code..

  • User Avatar
    0
    abu created

    yes sir i used a template ...

  • User Avatar
    0
    hikalkan created
    Support Team

    At this point, the only thing I can is that: zip and send me your project, I will try it myself. Is that possible?

  • User Avatar
    0
    abu created

    sir want to know your email id...???

    thank you so much sir for your support

  • User Avatar
    0
    abu created

    internal error occurs during your request means ...???

    please reply.. thank you

  • User Avatar
    0
    hikalkan created
    Support Team

    It means a server side error happen and it's hided from end user. You can see Logs folder of Web project. For more information, please read the Exception Handling doc: <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Handling-Exceptions">http://www.aspnetboilerplate.com/Pages/ ... Exceptions</a>

  • User Avatar
    0
    abu created

    thank you sir for all your support and guidance

    i want to know the use of Get() method in boilerplate ...??? I am using it but getting error may i know the the important points to remember for use of Get() method ..??

  • User Avatar
    0
    moneebkhalid created

    I am getting errors from autogenerated webAPI. Here is the content after hitting that url: ../api/AbpServiceProxies/GetAll?type=angular

    (function (abp, angular) {

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

    })((abp || (abp = {})), (angular || undefined));

    (function (abp, angular) {

    if (!angular) {
        return;
    }
    
    var abpModule = angular.module('abp');
    
    abpModule.factory('abp.services.app.user', [
        '$http', function ($http) {
            return new function () {
                this.prohibitPermission = function (input, httpParams) {
                    return $http(angular.extend({
                        abp: true,
                        url: abp.appPath + 'api/services/app/user/ProhibitPermission',
                        method: 'POST',
                        data: JSON.stringify(input)
                    }, httpParams));
                };
                
                this.removeFromRole = function (userId, roleName, httpParams) {
                    return $http(angular.extend({
                        abp: true,
                        url: abp.appPath + 'api/services/app/user/RemoveFromRole?userId=' + escape(userId) + '&roleName=' + escape(roleName) + '',
                        method: 'POST',
                        data: JSON.stringify({})
                    }, httpParams));
                };
                
            };
        }
    ]);
    

    })((abp || (abp = {})), (angular || undefined));

    (function (abp, angular) {

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

    })((abp || (abp = {})), (angular || undefined));

    (function (abp, angular) {

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

    })((abp || (abp = {})), (angular || undefined));

    (function (abp, angular) {

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

    })((abp || (abp = {})), (angular || undefined));

    (function (abp, angular) {

    if (!angular) {
        return;
    }
    
    var abpModule = angular.module('abp');
    
    abpModule.factory('abp.services.app.task', [
        '$http', function ($http) {
            return new function () {
                this.getTasks = function (input, httpParams) {
                    return $http(angular.extend({
                        abp: true,
                        url: abp.appPath + 'api/services/app/task/GetTasks',
                        method: 'POST',
                        data: JSON.stringify(input)
                    }, httpParams));
                };
                
                this.updateTask = function (input, httpParams) {
                    return $http(angular.extend({
                        abp: true,
                        url: abp.appPath + 'api/services/app/task/UpdateTask',
                        method: 'POST',
                        data: JSON.stringify(input)
                    }, httpParams));
                };
                
                this.createTask = function (input, httpParams) {
                    return $http(angular.extend({
                        abp: true,
                        url: abp.appPath + 'api/services/app/task/CreateTask',
                        method: 'POST',
                        data: JSON.stringify(input)
                    }, httpParams));
                };
                
            };
        }
    ]);
    

    })((abp || (abp = {})), (angular || undefined));

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Can you share the error. Output script seems good.