在angular js中,如何使用锚标签和$stateProvider来重定向到另一个页面
how to use anchor tags with $stateProvider to redirect to another page in angular js ?
我有一个登录页面忘记密码锚标签,在我忘记密码链接的点击上,我应该被重定向到我忘记的密码页面,我无法重定向它,我使用$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'
}
}
})
}]);
这是我的forgotpwd.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
。e ui-sref="app.forgotPassword"
更改:
<div class="forgot-pass"><a ui-sref="forgot">Forgot password?</a></div>
To:
<div class="forgot-pass"><a ui-sref="app.forgotPassword">Forgot password?</a></div>
相关文章:
- 有没有任何方法可以将控制器从文件加载到ui路由器$stateProvider中
- 通过javascript重定向html传递php变量
- JavaScript下拉菜单-点击按钮并根据所选值重定向到url
- 使用angular重定向到html页面
- 如何在chrome扩展中重定向到html页面
- 无法从jquery Mobile导航栏重定向到另一个页面
- 主干集合重置和解析
- ng视图外的链接重定向到ng视图内的页面
- 在phonegap应用程序内部重定向不起作用
- JavaScript:在源404上重试
- CORS-重定向到第二个GET正在接收的页面
- AJAX不会在文件上传后重定向到网页-POST方法
- 重定向时角度刷新浏览器
- 通过链接重定向不;我不在jstree中工作
- 根据select选项元素将表单重定向到不同的URL
- 通过JQuery重定向到另一个页面
- 重定向到“父窗口”
- 重定向iFrame中的父URL
- PHP-如何重定向到同一页面并更改DOM's
- 在angular js中,如何使用锚标签和$stateProvider来重定向到另一个页面