简体   繁体   中英

ng-include cannot locate partial html files

I'm trying to implement a basic tabset with each tab getting its content from a separate partial view with it's own controller. I have created three dummy HTML files with basic text only just to test the pipes but I can't seem to get ng-include working. I'm not sure how to use it regarding paths. My HTML files are in /Areas/SEFlex/Views/Home/, my angular controllers are in /app/SEFlex/controllers

This is my tab HTML

<div class="col-md-12">
            <tabset>
                <tab heading="Jobs" ng-show="AuthService.canRunFlexJobs || AuthService.canRunHighPriorityFlexJobs">
                    <div ng-include="'SEFlex/Home/Jobs.cshtml''"></div>
                </tab>
                <tab heading="Models" ng-show="AuthService.canViewFlexModels">
                    <div>test</div>
                </tab>
                <tab heading="Administrator" ng-show="AuthService.canAdministerFlex">
                    <div ng-include="'SEFlex/Home/Administrator.cshtml''"></div>
                </tab>
            </tabset>
        </div>

Have I got the relative paths wrong?

您只是语法上有一个额外的单引号。

<div ng-include="'SEFlex/Home/Jobs.cshtml'"></div> 

This is how I did it.

Controller

public ActionResult Index(string id)
{
    switch (id.ToLower())
    {
        case "index":
            return View();
        case "search":
            return PartialView("~/Views/App/SearchResults.cshtml");
        default:
            throw new Exception("template not known");
    }
    //return View();
}

HTML

<md-tab label="Search and Results">
    <div ng-include="'Home/Index/search'"></div>
</md-tab> <br>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM