Base solution for your next web application
Open Closed

Routing to another view with parameters #3482


User avatar
0
pumbinha created

Hi all,

I've been yesterday a couple of hours struggling my mind and I didn't get a solution yet.

First of all, this is an "usecase" that often occurs and maybe it wouldn't be a bad idea, if something like this is included in the base template of Aspnet Zero.

I'm using the SPA Version with Angular 1.x (4.0).

There are many occasions where after searching for an element in a Table, I would like to open it to view the details and the pop-up solution is not enough, I'm already a beginner in Angular, but it's quite simple: after clicking a link/button, I want to route the request to a new view including parameters in the url to load the content properly.

To achieve this I first registered the new view in app.js:

$stateProvider.state('tenant.product', {
                url: "/product",
                templateUrl: '~/App/tenant/views/products/view.cshtml',
        });

First question is: should the parameters somehow be included in this route?

In my index view, where all the products are listed I should have a link to redirect to the new view (view.cshtml) and this view should have a mechanism to read the parameters, and that's the point that I don't find in AspNet zero, because all SPA views open other views through popups.

Could you please give me a couple of clues to go on?

Thanks!


2 Answer(s)
  • User Avatar
    0
    pumbinha created

    I found some examples like here: <a class="postlink" href="https://stackoverflow.com/questions/39811845/angularjs-routing-with-parameters">https://stackoverflow.com/questions/398 ... parameters</a>

    but I don't know if this will work with Aspnet zero. In App.js there is no $routeProvider that I can reference :(

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    AspNet Zero contains a sample of this for changing texts of a language. You can check that, starting here <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero/blob/dev/src/MyCompanyName.AbpZeroTemplate.Web/App/common/views/languages/index.js#L134">https://github.com/aspnetzero/aspnet-ze ... ex.js#L134</a>.

    Please let us know if it does not work for you.

    Thanks.