[英]The href doesn't refresh when the ui-sref changes
I have an issue with angular. 我有棱角问题。 I have this code in my template :
我的模板中有以下代码:
<select class="form-control"
ng-model="hiveReports.reportSelected"
ng-options="link for link in hiveReports.reportsLink"
ui-sref="dashboard.hive-reports.{{hiveReports.reportSelected}}">
</select>
and the code behind like this : 和后面的代码是这样的:
.config(['$stateProvider', function ($stateProvider) {
$stateProvider
.state('dashboard.hive-reports', {
url: '/hive-reports',
template: require('./hiveReports.tmpl.html'),
abstract: true,
controller: 'HiveReportsCtrl as hiveReports'
});
}])
.controller('HiveReportsCtrl', [
'$rootScope',
'$state',
function ($rootScope,
$state) {
var controller = this;
controller.reportSelected = 'transactions';
controller.reportsLink = ['transactions','devices'];
}])
It create a select and switch the state when I select an option. 当我选择一个选项时,它会创建一个选择并切换状态。
In another template, it works fine but I have a parameter in the link like this 在另一个模板中,它工作正常,但是我在链接中有一个像这样的参数
<select class="form-control"
ng-model="hiveProfile.selectedProfile "
ng-options="profile.id as profile.name for profile in hiveProfile.profile"
ui-sref="dashboard.hive-profile.profile({profileId:hiveProfile.selectedProfile })">
</select>
I think the dashboard.hive-project.profile() trigger an event which refresh the href but without param, it doesn't work. 我认为dashboard.hive-project.profile()触发了一个刷新href的事件,但没有参数,则不起作用。 I have tried a lot of possibilities but nothing work.
我尝试了很多可能性,但没有任何效果。 Trying to trigger an event in the angular directive like that
试图像这样在angular指令中触发事件
ui-sref="dashboard.hive-reports.{{hiveReports.reportSelected}}()">
or 要么
ui-sref="dashboard.hive-reports.{{hiveReports.reportSelected}}({})">
Any ideas to fix my problem? 有解决我问题的想法吗?
I don't think you can use template tags like that in the ui-sref
. 我认为您不能在
ui-sref
使用像这样的模板标签。 I think you need to create a state and pass the dynamic reportSelected
in like you did with the profile one. 我认为您需要像创建配置文件一样创建状态并传递动态
reportSelected
。
$stateProvider
.state('dashboard.hive-reports', {
url: '/hive-reports',
template: require('./hiveReports.tmpl.html'),
abstract: true,
controller: 'HiveReportsCtrl as hiveReports'
})
.state('dashboard.hive-reports.report', {
url: '/{report}',
template: require('./hiveReportsReport.tmpl.html'),
controller: 'HiveReportsReportCtrl as hiveReportsReport'
});
<select class="form-control"
ng-model="hiveReports.reportSelected"
ng-options="link for link in hiveReports.reportsLink"
ui-sref="dashboard.hive-reports.report({report: hiveReports.reportSelected})">
</select>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.