Casper Nybroe
Casper Nybroe

Reputation: 1199

MVC, Render HTML page which includes AngularJS

I have a site build in MVC5 and C#. In this site I have a view (public.cshtml). In this view I have some text and beneith this text I would like to render another view (angular.html). The anguar.html view contains some angular script. How do I render the html page in the cshtml page correctly? Or is it even possible?

I have tried using Partial, RenderPartial and RenderPage but with no succes.

Any help is appreciated! Thanks in advance.

Upvotes: 0

Views: 687

Answers (1)

Ilya Luzyanin
Ilya Luzyanin

Reputation: 8110

It depends on whether your public.cshtml is "covered" with ngApp or all angular-related stuff is in that "angular.html".

If it's the first, you could use ng-include:

<ng-include src="'/...'"></ng-include>

if it's the latter, you could use @Html.Raw(), like this

@Html.Raw(File.ReadAllText(Server.MapPath("~/...")))

where "..." is your relative path to angular.html.

Upvotes: 1

Related Questions