我无法做到这一点,遇到很多错误我怎样才能检查包含该值的ng-switch是否为空并且在ng-switch中比较两个值并加载部分值。
查看档案
<div ng-switch="{{snl}} !='' ">
<div ng-switch-when="{{sln}}=='admincat' " ng-include src="'/eve/public_html/partials/admincat.html'"></div>
<div ng-switch-default ng-include src="'/eve/public_html/partials/adminuser.html'"></div>
</div>
控制器
$scope.grFunc = function (sidebar) {
$scope.sln = sidebar;
console.log($scope.sln);
};
答案 0 :(得分:1)
<div ng-if="snl">
<div ng-switch="snl">
<div ng-switch-when="admincat">test</div>
<div ng-switch-default>test2</div>
</div>
</div>
小提琴:https://jsfiddle.net/Lteftb0s/ 将ng-init更改为test!
答案 1 :(得分:0)
试试这个......
<div class="content" ng-switch on="snl">
<div ng-switch-when="admincat">
<div ng-include="'template1.html'"></div>
</div>
<div ng-switch-default>
<div ng-include="'template2.html'"></div>
</div>
</div>