Im fighting with angular to make it ng-include a partial cshtml view outside of ng-view.
here is my main view:
&
When dealing with MVC and AngularJS, just as long as you follow any defined route(s) {Controller}/{Action}... pattern, then you should be OK. Remember you're no longer really dealing with pages URL here, but rather actions.
You can also define a $routeProvider in an app.js file, in a similar fashion:
app.config(function ($routeProvider) {
$routeProvider
.when('/login',
{
controller: 'LoginController',
templateUrl: 'http://mysite/Account/Login'
})
.when('/register',
{
controller: 'RegisterController',
templateUrl: 'http://mysite/Account/Register'
})
.when('/main',
{
controller: 'HomeController',
templateUrl: 'http://mysite/Home/Index'
})
.otherwise({ redirectTo: '/main' });
});
To call partial view in asp.net mvc5
using angular js
, write this way:
<ng-include src="'@Url.Action("method_name", "Controller_name")'"></ng-include>
and it also remember your controller method must return this way:
return PartialView("~/Views/Angular/TableAdd.cshtml");
Happy coding.
ng-include evaluates an expression, make sure if you're looking to load a path directly you use two sets of quotation marks.
<div ng-include="'Home/Template/login'"></div>