I'm trying to create conditional md-tabs
using ng-switch
.
I know that works fine with ng-if
but I would much appreciate the ng-switch-default
since there isn't ng-else
.
Here's a example 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>
and the script:
angular.module('app', ['ngMaterial'])
.controller('all', function($scope, $element) {
$scope.tabs = [
{label: 'tab1'},
{label: 'tab2'}];
});
I also wrote this codepen with this example. What am i doing wrong?
You need to wrap inside a div,
DEMO