首页 > 其他 > 详细

angular实现的tab栏切换

时间:2016-10-02 21:38:21      阅读:197      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>tab栏</title>
    <style>
        .active {
            background-color: orange;
        }
    </style>
    <script src="node_modules/angular/angular.js"></script>
</head>
<body ng-app="s1.app">
<div>
    <button ng-class="{ ‘active‘ : data.current == 1 }" ng-click="actions.setCurrent(1)">张三</button>
    <button ng-class="{ ‘active‘ : data.current == 2 }" ng-click="actions.setCurrent(2)">李四</button>
    <button ng-class="{ ‘active‘ : data.current == 3 }" ng-click="actions.setCurrent(3)">王五</button>
</div>
<div>
    <div ng-if="data.current == 1">张三的个人信息</div>
    <div ng-if="data.current == 2">李四的个人信息</div>
    <div ng-if="data.current == 3">王五的个人信息</div>
    <script>
        var app = angular.module(‘s1.app‘, []);
        app.run(function ($rootScope) {
            $rootScope.data = {
                current: "1" // 1代表张三,2代表李四,3代表王五
            };
            $rootScope.actions =
            {
                setCurrent: function (param) {
                    $rootScope.data.current = param;
                }
            }
        })
    </script>
</div>
</body>
</html>

 

angular实现的tab栏切换

原文:http://www.cnblogs.com/lsy0403/p/5927993.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!