【发布时间】:2016-07-05 20:00:05
【问题描述】:
我正在使用带有 Angular 的 ui-router,我的想法是 UI 布局中的下拉菜单(也是父状态)有一个下拉菜单会更改子状态中的数据。
路由:
.state('App', {
url : '/',
controller : 'AppController',
templateUrl : 'views/layout.html',
})
.state('App.userProfile', {
parent : 'App',
url : 'profile',
templateUrl : 'views/user-profile.html',
controller : 'UserProfileController'
})
HTML 下拉菜单:
<div class="top-bar">
<div class="top-bar-logo"></div>
<label>Active team</label>
<select class="clean-custom-select margin-bottom-10"
ng-options="team._id as team.Name for team in userTeams"
ng-change="changeActiveTeam(ActiveTeamModel)"
ng-model="ActiveTeamModel">
<option value="">Choose a team</option>
So what I am trying to achieve is when the select dropdown changes the child view will reload with the relevant changes.However, this has to work for all child states.上面的代码只是一个子状态的例子,其实还有很多。
对于更多上下文,下拉列表将包含团队名称。一旦用户选择了一个团队,所有子状态都应该引用该团队。
【问题讨论】:
标签: javascript angularjs angular-ui-router