【问题标题】:ng-switch-when-separator not working in angularJSng-switch-when-separator 在 angularJS 中不起作用
【发布时间】:2017-02-23 21:48:28
【问题描述】:

ng-switch 在我使用 ng-switch-when-separator 时不起作用。 当我选择 settings 开关指向默认 div

angular.module("myModule", [])
 .controller("myController", function ($scope) {
    $scope.items = ['settings', 'home', 'options', 'other'];
    $scope.opt = $scope.items[0];
  });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="myModule">
    <div ng-controller="myController">
        <select ng-model="opt" ng-options="item for item in items">
        </select>
        <code>selection={{opt}}</code>
        <hr />
        <div class="animate-switch-container"
            ng-switch on="opt">
            <div class="animate-switch" ng-switch-when="settings|options" ng-switch-when-separator="|">Settings Div</div>
            <div class="animate-switch" ng-switch-when="home">Home Span</div>
            <div class="animate-switch" ng-switch-default>default</div>
        </div>
    </div>
</body>

【问题讨论】:

标签: html angularjs angularjs-directive angularjs-ng-switch


【解决方案1】:

这是文档页面的问题,但不是 Angular 本身的错误。 会发生什么:

  • 文档默认显示当前 master 分支(也称为快照)的 API
  • 嵌入式 plnkrs 还使用来自 master 分支的内置 angular 文件
  • 自动创建的 plnkrs 回退到尚不支持分隔符的最新稳定版本(在这种情况下为 1.5.8)。

所以您必须等待 1.5.10 才能使用该功能。

【讨论】:

    猜你喜欢
    • 2015-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-06
    相关资源
    最近更新 更多