关于angular的一些优点就不介绍了,感兴趣的可以看一下http://www.zhihu.com/question/22284218。
废话不多说,粗暴点,直接上代码。
<button ng-click="tab('tab.html')">1</button>
<button ng-click="tab('tab1.html')">2</button>
<div ng-include="tabs"></div>
<script type="text/ng-template" id="tab.html">
tab1
</script>
<script type="text/ng-template" id="tab1.html">
tab2
</script>
<script type="text/javascript">
var app = angular.module('myApp',[]);
app.controller('MyController',['$scope',function($scope){
$scope.tabs = "tab.html";
$scope.tab = function(param){
$scope.tabs = param;
}
}])
</script>