用angular渲染bootstrap中的tab切換的思路:先載入scope中的tabs,然後利用後臺bootstrap渲染即可。
1、angularjs程式碼:angular.module("TabsApp",[]).controller("TabsCtrl",["$scope",function($scope){ $scope.tabs=[{ title:"One", url:"one.tpl.html" },{ title:"Two", url:"two.tpl.html" },{ title:"Three", url:"three.tpl.html" }]; $scope.currentTab="one.tpl.html"; $scope.onClickTab=function(tab){ $scope.currentTab=tab.url; } $scope.isActiveTab=function(tabUrl){ returntabUrl==$scope.currentTab; }}]);
2、渲染效果:
用angular渲染bootstrap中的tab切換的思路:先載入scope中的tabs,然後利用後臺bootstrap渲染即可。
1、angularjs程式碼:angular.module("TabsApp",[]).controller("TabsCtrl",["$scope",function($scope){ $scope.tabs=[{ title:"One", url:"one.tpl.html" },{ title:"Two", url:"two.tpl.html" },{ title:"Three", url:"three.tpl.html" }]; $scope.currentTab="one.tpl.html"; $scope.onClickTab=function(tab){ $scope.currentTab=tab.url; } $scope.isActiveTab=function(tabUrl){ returntabUrl==$scope.currentTab; }}]);
2、渲染效果: