【问题标题】:ui-view is not rendering the corresponding template for angular-ui-tab?ui-view 没有为 angular-ui-tab 渲染相应的模板?
【发布时间】:2016-08-12 13:06:54
【问题描述】:

ui-view 不适用于 ui-tab。请查看场景,并请告诉我我错在哪里。

在客户页面中,我正在调用页面更新客户,通过单击任何客户customers.view.html,此页面包含客户列表。当我点击任何客户时,它会打开类似以下 url 的链接。 http://localhost:3000/home/#/updatecustomer/5

customers.view.html

<a><i ui-sref="home.updatecustomer({ customerId: {{customer.id}} })" class="fa fa-edit pull-right" ng-click="$event.stopPropagation()"></i></a>

在配置中,我正在创建 url http://localhost:3000/home/#/updatecustomer/5,我可以打开页面 index.html,但是查看相应的配置文件和设置没有打开...

请看类似的工作演示Working DEMO

配置

.state('home.updatecustomer', {
     url: 'updatecustomer/:customerId',
     views:{
              '':{
                  templateUrl: 'addcustomer/index.html',
                  controller: 'TabsDemoCtrl',
              },
              'profile':{
                  templateUrl: 'addcustomer/profile.html'
              },
              'setting':{
                  templateUrl: 'addcustomer/setting.html'
              },
            }
     })

控制器

var app = angular.module('app') ;
    app.controller('TabsDemoCtrl', TabsDemoCtrl);
    TabsDemoCtrl.$inject = ['$scope', '$state'];
    function TabsDemoCtrl($scope, $state){
        $scope.tabs = [
            { title:'profile', view:'profile', active:true },
            { title:'setting', view:'setting', active:false }
        ];
    }

index.html

  <uib-tabset active="active">
    <uib-tab  ng-repeat="tab in tabs" heading="{{tab.title}}" active="tab.active" disable="tab.disabled">
        <div ui-view="{{tab.view}}"></div>
    </uib-tab>
</uib-tabset>

profile.html

  <div>profile of customer </div>

Setting.html

  <div>Setting for customer </div>

【问题讨论】:

  • 从 ui-view 中删除括号,它不需要。不知道是不是这个问题……
  • @GustavoGabriel 我删除但仍然无法正常工作,我认为这不会有任何问题,因为在工作演示中,我们使用的是相同的东西......
  • @geeks 你能在你的 plunkr 中添加配置吗??

标签: javascript html angularjs


【解决方案1】:
<a><i ui-sref="home.updatecustomer({ customerId: customer.id })" class="fa fa-edit pull-right" ng-click="$event.stopPropagation()"></i></a>

试试这个,因为 atn 也提到我有同样的想法希望它有帮助

【讨论】:

    【解决方案2】:

    ui-sref 中应该有不带括号的customer.id

    <a ui-sref="home.updatecustomer({ customerId: customer.id })" class="pull-right"><i class="fa fa-edit"></i></a>
    

    如果您能够将状态更改为home.updatecustomer,那么标签应该可以工作。

    更新

    固定属性:

    • ui-sref 传递给a 标签
    • pull-right 类传递给a 标记

    【讨论】:

      猜你喜欢
      • 2015-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-23
      • 1970-01-01
      相关资源
      最近更新 更多