mvc - Angular ng-include cshtml page

ID : 274313

viewed : 32

Tags :

Top 4 Answer for mvc - Angular ng-include cshtml page

vote vote


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> 
vote vote


To call partial view in 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.

vote vote


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' }); });     
vote vote


Top 3 video Explaining mvc - Angular ng-include cshtml page