【发布时间】: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>
【问题讨论】:
-
Their demo 做同样的事情......看起来像一个错误。单击“在 Plunker 中编辑”按钮。这很奇怪,因为它适用于文档页面。
-
我查看了文档页面上的
iframesource for the example - 看起来它已在 1.5.9 中修复,因为它使用的是该版本的 angular.js。 -
这是使用您的代码的证明 - plnkr.co/edit/tJSs8TDLUsuajr551jpw?p=preview 您可以获取 1.5.9 版本 here 并验证它是否适合您。
标签: html angularjs angularjs-directive angularjs-ng-switch