asp.net mvc - Angular ng-include cshtml page

ID : 274313

viewed : 32

Tags : asp.net-mvcangularjsrazorasp.net-mvc





Top 4 Answer for asp.net mvc - Angular ng-include cshtml page

vote vote

97

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

81

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.

vote vote

75

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

65

Top 3 video Explaining asp.net mvc - Angular ng-include cshtml page







Related QUESTION?