Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

ng-include not working ASP.NET MVC - Angular 1.x #2631


User avatar
0
bilalhaidar created

Hi,

In one of the cases, I have a createModal and editModal. They both share the same form. So I thought of grouping the form in one single cshtml and load it inside both modals with:

<div ng-include="/App/tenant/views/refdata//createOrEditModal.cshtml" />

I can see with the Google Chrome developer tools that there is no request to server to bring in the cshtml file.

I've done this before outside this framework and works well.

Any idea?

Regards Bilal


4 Answer(s)
  • User Avatar
    0
    bilalhaidar created

    Even with this, it doesn't work:

    <div ng-include src="/App/tenant/views/refdata//createOrEditModal.cshtml" />
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Do you have an exception message ? I'm not sure this works on *.cshtml files, can you first try with a dummy *.html file ?

  • User Avatar
    0
    bilalhaidar created

    No exceptions are generated.

    Also, looking at Chrome Developer Tools, no request is sent to server.

    I tried with .html and same issue.

    Can you try it at your end?

    Regards Bilal

  • User Avatar
    0
    bilalhaidar created

    Seems the ng-include is failing silently with no hope to make it work.

    However, with MVC, I could do something like this given I am using .cshtml views for Angular:

    @Html.Partial("~/App/tenant/views/refdata/shelters/_createOrEditModal.cshtml")
    

    This works perfect.

    Question, can you please tell me, how does Angular capture a request for .cshtml (how does it deal with it) and how is i tbeing served on server? Maybe some references in the source code to look at and see how it works.

    Regards Bilal