您的位置:首页 > Web前端 > AngularJS

angular tab切换

2016-06-04 00:00 567 查看
摘要: 用angular 的 ng-template实现tab选项卡切换

关于angular的一些优点就不介绍了,感兴趣的可以看一下http://www.zhihu.com/question/22284218

废话不多说,粗暴点,直接上代码。
[code=language-javascript]<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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: