我有一个带有忘记密码 anchor 标记的登录页面,单击忘记密码链接后,我应该重定向到忘记密码页面,但我无法重定向它,我正在使用 $stateProvider 相应地路由我的页面,请帮我解决这个问题。
这是我的 login.html 页面,其中包含忘记密码链接:
<div class="input-element-row">
<div class="forgot-pass"><a ui-sref="forgot">Forgot password?</a></div>
</div>
这是我的 router.js,其中包含页面路由:
angular.module("nk.login", [
'ngRoute',
'ngAnimate'
]).
config(['$stateProvider',function($stateProvider){
$stateProvider
.state('app.login', {
url: '/login',
views: {
"content": {
templateUrl: 'src/login/templates/login.html',
controller: 'loginController'
}
}
})
.state('app.forgotPassword', {
url: '/forgot',
views: {
"content": {
templateUrl: 'src/login/templates/forgotPassword.html',
controller: 'forgotPasswordController'
}
}
})
}]);
这是我的forgetpwd.html 页面:
<div class="inputs-container">
<form name="forgotPassword" novalidate>
<div class="input-element-row">
<div class="rgt-input-box fl"><span class="center-icon action-icon"></span><input type="text"
ng-model="Nuser.center_code" placeholder="Center Code" name="CenterCode" value=""
ng-pattern = "/^[0-9a-zA-Z]*$/" maxlength="5" required ng-disabled="isDisable"/></div>
<div class="cb">
</div>
</div>
<div class="input-element-row">
<div class="rgt-input-box fl"><span class="user-icon action-icon"></span><input type="text"
placeholder="User ID" ng-model="Nuser.login_id" name="UserID" value=""
ng-pattern = "/^[0-9a-zA-Z]*$/" maxlength="10" required ng-disabled="isDisable"/></div>
<div class="cb"></div>
</div>
<div class="input-element-row">
<button type="button" name="send" ng-click="send(userLogin)">Send</button>
</div>
</form>
</div>
最佳答案
ui-sref
使用 state
而不是 url
。
因此您必须传递州名称而不是 url。
即ui-sref="app.forgotPassword"
更改:
<div class="forgot-pass"><a ui-sref="forgot">Forgot password?</a></div>
致:
<div class="forgot-pass"><a ui-sref="app.forgotPassword">Forgot password?</a></div>
关于javascript - 如何使用 anchor 标记与 $stateProvider 重定向到 Angular js 中的另一个页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32348915/