angular 和 ionic - ng-switch 改变 url

angular and ionic - ng-switch to change url

我正在开发一个 angular 应用程序,我正在尝试使用 ng-switch 设置中继器。

我目前的代码如下所示:

<ion-content>
    <ion-list>
        <ion-item menu-close ng-repeat="room in rooms" ng-switch="room.id" href="#/app/details/{{room.id}}" id="room-list-entry-{{room.id}}" class="item item-icon-right">

           <!--Template for id 0-->
           <div ng-switch-when="0" class="myHouse">
                testing template id 0
            </div>

            <!--Template for all the other rooms-->
            <div ng-switch-default class="rooms">
                testing template all the others
            </div>
          </ion-item>
     </ion-list>

ng-switch 工作正常,因为我可以看到正确的文本,我现在遇到的问题是我需要将 url 更改为这样的内容:

<a href="{{if room id == 0}}#/app/house{{else}}#/app/details/{{room.id}}{{/if}}"> 

这是我一直坚持的一点,因为我真的不知道是否可以用 ng-if 以这种方式做某事。

我知道最简单的方法是将 href 移动到 ng-switch-when 中,但问题是如果我移动它,离子框架打印的列表将不再正确呈现。 ..

如何根据 id 以正确的方式使用 angular 更改 link?

谢谢

-href 的使用:

<a ng-href="{{room.id == 0 ? '#/app/house' : '#/app/details/' + room.id}}">

http://jsfiddle.net/sm4xpe58/