我在这里只是想知道angular2视图是否适用于cshtml文件?我实际上是在mvc中实现用户和角色,并且认为我会在我的cshtml页面中渲染angular2 html页面,但这对我来说似乎是不可能的。我正在做的是:
TestController.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace UserDemo.Controllers
{
public class TestController : Controller
{
// GET: Test
public ActionResult Index()
{
return View();
}
[ChildActionOnly]
public ActionResult GetHtmlPage(string path)
{
return new FilePathResult(path, "text/html");
}
}
}
TestController的Index.html:
@{
ViewBag.Title = "Index";
}
<h2>Test</h2>
<div>
@Html.Action("GetHtmlPage", "Test", new { path = "~/index.html" })
</div>
Index.html是我的angular2视图,但它在cshtml中加载时会产生错误!