0

I have selected Single page application(MVC,Web api) in visual studio. Then create two Asp.net MVC controllers with the name of HomeController and AdminController.

In Asp.net MVC HomeController, i have 2 partial view first one is ShowStudents and second one is showTeachers. In AdminController, i have 2 partial view first one to AddStudent and second one AddTeachers.

In _Layout.html page i have initialize my angular app ng-app="myApp" and in Index.cshtml view of HomeController add the ng-view directive to display partial view data(of ShowStudents and ShowTeachers).Its woking fine but now the question is

how to display partial view(AddStudent and AddTeacher) of AdminController in Asp.net MVC Single page application?

ekad
  • 14,436
  • 26
  • 44
  • 46
Samir Rawat
  • 53
  • 1
  • 2
  • 8
  • possible duplicate of http://stackoverflow.com/questions/21089917/how-to-return-partial-view-of-another-controller-by-controller – ADyson Aug 24 '16 at 10:47
  • no in my Single page application, i have ng-view in HomeController Index view and i am not be able to bind other controller view in that ng-view – Samir Rawat Aug 24 '16 at 13:05
  • @ADyson can you help me? – Samir Rawat Aug 24 '16 at 13:19
  • did you read the question i posted the the link to? Did nothing there help you? – ADyson Aug 24 '16 at 13:24
  • @ADyson yes i have readed.. but my requirement is in Single page application to add multiple Asp.Net MVC Controller and calling their views(cshtml) in single ng-View directive of angularJS which is totally different from that – Samir Rawat Aug 24 '16 at 13:50
  • so you can't use @Html.Partial to inject the view data? If you mean you're trying to do it dynamically then you probably need to use ajax to return the HTML from the partial. – ADyson Aug 24 '16 at 13:51
  • @ADyson no i am using return PartialView("Post"); inn my Asp.net MVC controller and its working fine. i have used ng-view directive of angularJS to bind all view one by one its working fine for all view of same controller only but i want to call another controller view in it which is not working – Samir Rawat Aug 24 '16 at 14:00
  • and an example like `return PartialView("~/views/ABC/XXX.cshtml", zyxmodel);` as per that answer I linked you to doesn't work? – ADyson Aug 24 '16 at 14:01
  • @ADyson Its not working for me because i have two Asp.Net MVC controller and call second controller view through their action method in first one controll and then bind it in `ng-view` directive in Index.chtml of angularJS .... but ng-view directive in Index.cshtml view only allow their own controller action methods only – Samir Rawat Aug 24 '16 at 16:24
  • so you're chaining controller actions together? I don't know if that's the cause of your problem but it doesn't sound like a very good design in general. – ADyson Aug 24 '16 at 16:35
  • yes @ADyson and i am new in Single page application in asp.net mvc . i am trying to create large Single page application using Asp.net MVC and angularJS where i can create multiple Asp.net mvc Controllers and view .. is it possible? – Samir Rawat Aug 24 '16 at 16:48
  • if you just want a single page app, you might be better using one single MVC view which simply loads the page, and then some Web API controllers which return JSON data to your app from the server. Then define all your views using angular. – ADyson Aug 25 '16 at 07:27
  • ok but is it possble with multiple asp.net MVC controllers and views in angularJS single page application? – Samir Rawat Aug 25 '16 at 09:30
  • i don't know, i've never tried. But I'd have thought it was simpler to define them in angular - angular has its own view system, you might as well use that – ADyson Aug 25 '16 at 09:31

0 Answers0