1

我有角度问题。我的模板中有这段代码:

<select class="form-control"
  ng-model="hiveReports.reportSelected"
  ng-options="link for link in hiveReports.reportsLink"
  ui-sref="dashboard.hive-reports.{{hiveReports.reportSelected}}">
</select>

和后面的代码是这样的:

.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'];
      }])

当我选择一个选项时,它会创建一个选择并切换状态。

在另一个模板中,它工作正常,但我在链接中有一个参数,如下所示

<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>

我认为dashboard.hive-project.profile() 触发了一个刷新href 但没有参数的事件,它不起作用。我尝试了很多可能性,但没有任何效果。试图在这样的角度指令中触发事件

ui-sref="dashboard.hive-reports.{{hiveReports.reportSelected}}()">

或者

ui-sref="dashboard.hive-reports.{{hiveReports.reportSelected}}({})">

有什么想法可以解决我的问题吗?

4

1 回答 1

1

我认为您不能在ui-sref. 我认为您需要创建一个状态并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>
于 2015-06-09T20:42:40.597 回答