简体   繁体   English

在asp.net mvc应用程序中显示angular2应用程序

[英]display angular2 app within asp.net mvc application

Referenced Tutorial I am following this tutorial but i wanted to display my angular2 app based on a tab click from the menu rather than have it default load the angular app. 参考的教程我正在学习本教程,但是我想基于菜单中的选项卡单击显示我的angular2应用,而不是让它默认加载angular应用。 so in my mvc i have a menu bar : Home, About, Contact tabs and i would like to load my angular2 app once i click the About tab... How can i configure that? 所以在我的mvc中,我有一个菜单栏:“主页”,“关于”,“联系人”选项卡,一旦我单击“关于”选项卡,我想加载我的angular2应用程序。我该如何配置呢?

How can i configure a link in asp.net mvc to route to the angular app? 如何在asp.net mvc中配置链接以路由到Angular应用程序? Would i have to change the app/main.ts and the systemjs.config.js file? 我是否需要更改app / main.ts和systemjs.config.js文件?

Step 1 第1步

Open _Layout.cshtml and cut angular scripts as follows: 打开_Layout.cshtml并按以下方式剪切角度脚本:

在此处输入图片说明

Step 2 第2步

Then remove 然后移除

<my-app>Loading...</my-app>

tag from Index.cshtml 来自Index.cshtml的标签

在此处输入图片说明

Step 3 第三步

and add it to About.cshtml . 并将其添加到About.cshtml中 Also add angular scripts that we have already copied from step1 to scripts section: 还要添加我们已经从step1复制到scripts部分的角度脚本:

在此处输入图片说明

That's all. 就这样。 Here is the result 这是结果

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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