【发布时间】:2017-01-02 16:05:26
【问题描述】:
我正在尝试使用ng-switch 创建条件md-tabs。
我知道ng-if 可以正常工作,但我非常感谢ng-switch-default,因为没有ng-else。
这是一个示例 html:
<div ng-controller="all">
<select ng-switch="var">
<option value="t1">Type 1</option>
<option value="t2">Type 2</option>
</select>
<md-tabs ng-switch="var">
<md-tab ng-switch-when="t1" label="{{tab.label}}" ng-repeat="tab in tabs">
<!-- content for tabs using type 1 -->
</md-tab>
<md-tab ng-switch-when="t2" label="{{tab.label}}" ng-repeat="tab in tabs">
<!-- content for tabs using type 2 -->
</md-tab>
</md-tabs>
</div>
和脚本:
angular.module('app', ['ngMaterial'])
.controller('all', function($scope, $element) {
$scope.tabs = [
{label: 'tab1'},
{label: 'tab2'}];
});
我还用这个例子写了this codepen。 我做错了什么?
【问题讨论】:
标签: angularjs angular-material ng-switch