繁体   English   中英

如何使用 angular 通过单击单页应用程序中的按钮重定向到另一个 HTML 页面?

[英]How to redirect to another HTML page by button click in a single page app using angular?

我正在开发一个包含登录和注册以及其他一些功能的单页应用程序。我有包含signin.htmlregister.html页面index.html ,并且register.html的提交应该将用户引导到welcome.html . 我了解如何使用ng-include将多个 html 页面放入一个页面,但是在这种情况下我该如何使用它?

试试include.html

<body  ng-app="myApp">
  <div >
     <div ng-include = "'tryinclude1.html'"></div>
  </div>

尝试包含1.html

<body>
<label>you are in tryinclude1 press ok to go to another page</label>
<button ng-include="'tryinclude1.html'">ok</button>
</body>

tryinclude2.html:

<body>
<label>you are in tryinclude2 press ok to go to another page</label>
<button ng-include="'tryinclude1.html'">ok</button>
</body>

感谢您的帮助

答案是使用 ng-hide 和 ng-show ,不需要路由。 更多细节在这里https://scotch.io/tutorials/how-to-use-ngshow-and-nghide

您可以使用 ng-view 和 ng-route 来管理您的单页应用程序。

https://docs.angularjs.org/api/ngRoute/directive/ngView

暂无
暂无

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

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