我正在嘗試通過我的web應用程序實現註冊服務的最簡單方法。該應用的着陸頁是登錄頁面,其中有一個鏈接到註冊頁面。我似乎無法簡單地重定向到部分標誌 - 我認爲它被身份驗證阻止。因此,我已將註冊表單包含在我的index.html中,並帶有登錄表單。我試圖弄清楚如何使用ng-show來顯示註冊表單,並在單擊註冊按鈕時隱藏註冊表單,但是遇到困難。任何人都可以建議如何做到這一點,或者如果有更好的方法?在角度js中呈現註冊表單通過身份驗證被阻止
的index.html
<html>
<head>
<title> Application</title>
//Links to stylesheets here
</head>
<body ng-app="myApp">
//This is what the user sees when they navigate to the page
<div ng-controller="SignInCtrl">
<div ng-show="!isAuthenticated" ng-hide = "signup">
<form class = "form-signin">
<div class="control-group">
<div class="controls">
<br />
<input type="text" ng-model="username">
</div>
<div class="controls">
<input type="password" ng-model="password">
</div>
<div class="controls">
<button class = "btn btn-default" ng-click="signIn()">Sign In</button>
//This is the link to sign up
<a ng-model = "signup">Sign Up</a>
</div>
</div>
</form>
</div>
<div ng-controller = "AccountNewController">
<div ng-show = "signup">
This is where my sign up form will appear when my signup button is clicked.
</div>
</div>
//This part of index.html is only shown when a user has been authenticated
<div ng-show="isAuthenticated">
<div class="col-md-2">
//Menu Bar code here
</div>
<div class="col-md-10">
//Other app partials are rendered here
<div ng-view></div>
</div>
</div>
</div>
//Links to JS files here
</body>
</html>
ng-show應該可以正常工作,可能是您的js代碼的問題 –
我沒有任何JS代碼用於ng-show指令嗎? – bookthief