标签:count end lsh type bsp mod code 路径 top
angular的标签栏,有两种方法实现:
详细例子如下:
<script>
var App = angular.module("App",[]); App.controller(‘DatailController‘,[‘$scope‘,function($scope){ $scope.detailDownTitle = { title :[ "选题详情","关联内容","推荐内容","流程日志" ], count : 0, datailShow : function(index){ if(index==0){ this.count=0; }else if(index==1){ this.count=1; }else if(index==2){ this.count=2; }else if(index==3){ this.count=3; }else{ } } }]);
</script>
HTML模板如下:
<div class="detailDown"> <ul class="detailDownTitle"> <li data-ng-repeat="title in detailDownTitle.title" data-ng-click="detailDownTitle.datailShow($index)"><a>{{title}}</a></li> //将$index传参,确定单击的哪一个Tab </ul>
<div data-ng-show="detailDownTitle.count==0">
<div>Tab1</div>
</div>
<div data-ng-show="detailDownTitle.count==1">
<div>Tab2</div>
</div>
<div data-ng-show="detailDownTitle.count==2">
<div>Tab3</div>
</div>
<div data-ng-show="detailDownTitle.count==3">
<div>Tab4</div>
</div>
</div>
主页index.html引入方式如下
<div class="detailContent" data-ng-include=" ‘topicDetail.html‘ " ng-controller= "DatailController"> //注意路径 </div>
script标签一样,HTML模板如下:
<div class="detailDown"> <ul class="detailDownTitle"> <li data-ng-repeat="title in detailDownTitle.title" data-ng-click="detailDownTitle.datailShow($index)"><a>{{title}}</a></li> </ul> <div data-ng-include=" ‘/topic/template/topicContent.html‘ " data-ng-if="detailDownTitle.count==0"></div> <div data-ng-include=" ‘/topic/template/linkContent.html‘ " data-ng-if="detailDownTitle.count==1"></div> <div data-ng-include=" ‘/topic/template/recommendContent.html‘ " data-ng-if="detailDownTitle.count==2"></div> </div>
如果后续发现新的实现方法,会继续总结
标签:count end lsh type bsp mod code 路径 top
原文地址:http://www.cnblogs.com/lovemomo/p/6115311.html