0

I have problem with angular routing and ASP.NET MVC. The problem is with URL.

MVC controller:

[RoutePrefix("BackOffice/Merchants")]
public class MerchantsController : Controller
{
    [Route("Add")]
    public ActionResult Add()
        => View("~/Views/BackOffice/Merchants/View.cshtml");
    [Route("{id}/Edit")]
    public ActionResult Edit(Guid id) // e08c5580-29e3-4429-9c76-b1464f0365ae
        => View("~/Views/BackOffice/Merchants/View.cshtml");
}

Angular app.js

 var app = angular.module("backofficeMerchantsApp", ["ngRoute"]);

app.config(function($routeProvider) {
    $routeProvider
        .when("/",
        {
            template: "<h1>eee</h1>"
        })
        .when("/Add",
        {
            templateUrl: "add.html",
            controller: "addController"
        });
});

And there is problem:

When I enter:

.../BackOffice/Merchants/Add 

The angular loads "/" page. When I enter:

.../BackOffice/Merchants/Add#/Add

The angular loads "/Add" page.

I don't want it. What I have done wrong?

I want to:

When I enter:

.../BackOffice/Merchants 

The angular loads "/" page. When I enter:

.../BackOffice/Merchants/Add

The angular loads "/Add" page.

How to do it?

1 Answer 1

0

I was able to figure this out here: Angular Routing with ASP MVC

Hope this helps if you are still having a hard time.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.