Reputation: 13
I´d like to know if exists a better way to render a view like this: For the first load I need bring data from Controller like usual but after apply a filter in same page I need to start use AngularJS and never more uses Razor. Is there a way to do that ? Thanks for all.
Upvotes: 1
Views: 207
Reputation: 62260
There are multiple ways to implement ASP.Net MVC with AngularJs.
I personally like Mini SPA (Silos). You can watch Miguel A Castro's video here.
You can also download the source at his website.
What it does is when a request comes in, it goes to ASP.Net MVC Route first. Then, Angular Route takes over the rest. It is a very slick design.
FYI: I also use Angular.Net Helpers to generate strongly typed views.
Upvotes: 0
Reputation: 21
Yes. You can make angular views and exchange data using $http.get(/controller/method/). You can also configure routing using ngRoute.
Upvotes: 0
Reputation: 394
You could use WebAPI project in visual studio to exchange data between frontend and backend. It would go stateless, so to secure the data, you could use a mechanism like JWT.
The frontend would exchange JSONS from/to the backend using REST apis.
Upvotes: 0
Reputation: 131
Yes. you can do that.
Basically, you'd need to add the line below in your view. After you do that, the json is going to be available to the DOM / javascript and angular can take it from there. Hope this help
var json = '@Html.Raw(Model.MyJsonStringForMyCoolAngularJsApp)';
Upvotes: 1