Base solution for your next web application
Open Closed

JavaScript Service Methods #4989


User avatar
0
gep13 created

Hello,

In the generated Index.js files for the entities I have created, I am seeing lines like this:

ajaxFunction: _computersService.getAll,

For querying all the records from the database. I have created a custom method in my controller that I want to call instead of the default getAll method, however, I am unable to find the _computersService defined anywhere to add that method to.

Can someone please point me in the right direction?

Thanks Gary


2 Answer(s)
  • User Avatar
    0
    strix20 created

    <cite>gep13: </cite> Hello,

    In the generated Index.js files for the entities I have created, I am seeing lines like this:

    ajaxFunction: _computersService.getAll,
    

    For querying all the records from the database. I have created a custom method in my controller that I want to call instead of the default getAll method, however, I am unable to find the _computersService defined anywhere to add that method to.

    Can someone please point me in the right direction?

    Thanks Gary

    Hey Gary,

    With Asp Zero, we don't create controller methods for javascript. ABP Framework dynamically generates proxies for all of your application services (defined in the Application project), and exposes them through dynamically created scripts.

    If you want to expose a custom function, you just need to add it to the corresponding Application Service.

    In your case, you want to find the computersService in your application project.

    Make sure to update the interface in the application.shared project, as well.

  • User Avatar
    0
    alper created
    Support Team

    hi,

    As @strix20 mentioned; no need to create a controller. The auto-generated javascript methods come from Application Services.

    Check out how to create a new application service <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Application-Services">https://aspnetboilerplate.com/Pages/Doc ... n-Services</a>

    If you add a new method to a already created application service, don't forget to add it to the interface and make it public.