Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

How to refer the angular 2 components in the Asp.Net5 MVC views/partial

$
0
0

I have a created a project with default Asp.net 5 - webapplication template. I added a Scripts folder under project and also added 2 typescripts file along with tsconfig file. I have configured the output directory to "outDir": "../wwwroot/appScripts/" in the tsconfig file to move all the .js files under specified folder.
Scenario# 1: When I try to render a partial view directly by setting the default route in startup.cs file, the angular components in .js file format under the specified appScripts/ folder and rendered properly and angular components works fine.
scenario# 2: But when I load a login page first, and then route to the above specified view using MVC controller/action method, i can notice that the angular components are not rendered, hence not working.

the following code i have given in the _Layout.cshtml file to refer the angular components:

<script>
        System.import('../appScripts/boot')
              .then(null, console.error.bind(console));</script>

Please refer the snapshot attached where-in in the scenario# 1 it renders the angular components but not in the scenario# 2
Can anyone help me how do i configure to refer the angular components under wwwroot/appScripts/ folder to be accessed in folder Views/Home/Index/Index.cshtml view ?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>