簡體   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