Tom el Safadi
Tom el Safadi

Reputation: 6796

Routing Asp.Net AngularJs

I am having a porblem with the ng-view which doesn't want to load. If I press on a link I get the following Url: http://localhost:63024/Home/Index#/routeOne

Code for my controller:

public class HomeController : Controller
{
    public ActionResult Index()
    {
        return View();
    }
    public ActionResult One()
    {
        return View();
    }

    public ActionResult Two()
    {
        return View();
    }

    public ActionResult Three()
    {
        return View();
    }
}

So a very simple Controller.

And the following routing:

var configFunction = function ($routeProvider) {
$routeProvider.
    when('/routeOne', {
        templateUrl: 'Home/one'
    })
    .when('/routeTwo', {
        templateUrl: 'Home/two'
    })
    .when('/routeThree', {
        templateUrl: 'Home/three'
    });
}
configFunction.$inject = ['$routeProvider'];

myApp.config(configFunction);

And the following view:

<ul>
   <li><a href="#/routeOne">Route One</a></li>
   <li><a href="#/routeTwo">Route Two</a></li>
   <li><a href="#/routeThree">Route Three</a></li>
</ul>

<div ng-view></div>

Upvotes: 0

Views: 465

Answers (1)

Tim Snow
Tim Snow

Reputation: 345

have you specified views for those controller actions in the mvc app, and ng-controller / ng-app on the angular side? (posting this as answer as i can't post a comment)

Upvotes: 1

Related Questions