1

我正在尝试在我的应用程序中使用 ng-switch。

In Routing configuration :

when('/Test/:TestName/formEditor/:openedFrom', {
        templateUrl: 'Testing.html',
        controller: 'TestCtrl'
    })

在我的 HTML

  <div ng-switch="openedFrom">
    <ul class="breadcrumb" ng-switch-when="fromTab1">
        <li><a href="#/solutions" id="act_
   </ul>
   <ul class="breadcrumb"  ng-switch-when="fromTab2" >
         <li><a href="#/abc">Visitors</a></li>
   </ul>
  </div>

我通过 Openedfrom 的方式是

  <a class="btn btn-primary" href="#/Test/{{TestName}}/formEditor/fromTab1">Tab 1</a>

  <a class="btn btn-primary" href="#/Test/{{TestName}}/formEditor/fromTab2">Tab 2</a>

面包屑根本不渲染。一旦我删除 ng-switch 一切似乎都可以正常工作。有人可以建议吗?

4

1 回答 1

0

这是因为您正在使用 `ng repeat` 和 `ng switch` 渲染 div。您可以通过 `ng-if` 使用。

<div>
   <ul class="breadcrumb" ng-if="openedFrom=='fromTab1'">
    <li><a href="#/solutions">Solutions</a></li>
   </ul>
   <ul class="breadcrumb"  ng-if="openedFrom=='fromTab2'" >
      <li><a href="#/abc">Visitors</a></li>
   </ul>
</div>
于 2014-11-26T07:11:19.977 回答