Thursday 15 March 2012

c# - Display HTML in ng-view with AngularJS in an ASP.NET MVC 5 project using ngroute -



c# - Display HTML in ng-view with AngularJS in an ASP.NET MVC 5 project using ngroute -

i trying utilize ngroute link html and/or cshtml document in asp.net mvc 5 project:

/views/home/index.cshtml:

<ul class="pager"> <li><a href="#/route1">route 1</a></li> <li><a href="#/route2">route 2</a></li> </ul> <div ng-view></div>

i've tried many ways type file-path i'm convinced it's way asp.net mvc handles routing , views, something i've learned here. here's latest effort @ templateurl element:

/scripts/app/app.js:

var app = angular.module('app', ['ngroute']); app.config(['$routeprovider', function ($routeprovider) { $routeprovider. when('/route1', { templateurl: '/views/modules/page1.html', controller: 'routecontroller' }). when('/route2', { templateurl: '/views/modules/page2.html', controller: 'routecontroller' }). otherwise({ redirectto: '/' }); }]); app.controller("routecontroller", function ($scope) { });

just in case it's needed, here's homecontroller.cs

/controllers/homecontroller.cs:

public class homecontroller : controller { public actionresult index() { homecoming view(); } public actionresult page1() { homecoming view(); } public actionresult page2() { homecoming view(); } public actionresult about() { viewbag.message = "your application description page."; homecoming view(); } public actionresult contact() { viewbag.message = "your contact page."; homecoming view(); } }

chrome's console tells me app.js's references page1 , page2 inaccurate, no matter do. help me understand what's going on?

c# asp.net asp.net-mvc angularjs visual-studio-2013

No comments:

Post a Comment