欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

angularjs实现时间轴效果的示例代码

程序员文章站 2022-06-18 08:23:02
一 引入包 引入angular-timeline包。 下载地址: 在index.html中引入

一 引入包

引入angular-timeline包。

下载地址:

在index.html中引入

<link href="lib/angular-timeline/dist/angular-timeline.css" rel="external nofollow" rel="stylesheet">
<script src="lib/angular-timeline/dist/angular-timeline.js"></script>

app.js中引用,不引用就没有效果。

angularjs实现时间轴效果的示例代码

二 改写css

根据需求改写css,核心部分的改写。

可以写在style.css中,也可以新建一个css文件,但是一定要在index.html中引用。

/* 时间轴 */
.timeline-event {
 margin-bottom: 0px !important;
}

timeline-badge.infos {
 background-color: #47d09e !important;
}

.timeline:before {
 width: 1px !important;
 left: 24px !important;
 margin-top: 30px !important;
 background-color: #47d09e !important;
}

timeline-badge {
 left: 16px !important;
 width: 15px !important;
 height: 15px !important;
 top: 15px !important;
 box-shadow: none !important;
}

timeline-panel {
 float: left !important;
 width: 85% !important;
 padding: 13px 0px 6px 0px !important;
 margin-left: 39px !important;
 background: none !important;
 border: none !important;
 box-shadow: none !important;
}

timeline-panel:before {
 visibility: hidden !important;
}

timeline-panel:after {
 visibility: hidden !important;
 display: none !important;
}

timeline-panel .time {
 font-size: 14px;
 font-family: 'pingfangsc-regular';
}

timeline-panel .detail {
 display: flex;
 display: -webkit-flex;
 align-items: center;
 -webkit-align-items: center;
 justify-content: space-between;
 -webkit-justify-content: space-between;
 margin-top: 10px;
}

timeline-panel .detail .linename {
 font-size: 16px;
 max-width: 80%;
 color: #1c1c1c;
 display: inline-block;
 font-family: 'pingfangsc-medium';
}

timeline-panel .detail .linelevel {
 position: absolute;
 right: 18%;
 border-radius: 4px;
 color: white;
 padding: 1px 5px 1px 5px;
 font-size: 11px;
}

timeline-panel .detail .linelevel-g {
 background-color: #f27373;
}

timeline-panel .detail .linelevel-p {
 background-color: #e29431;
}

timeline-panel .detail .linenum {
 float: right;
 font-size: 14px;
 color: #323232;
}

三 页面

准备工作做完了,下面是页面的编写。

<!--html页面-->
<ion-view view-title="{{title}}">
 <ion-content scroll="true">

  <timeline>
   <timeline-event ng-repeat="event in teamdatalist" side="right">
    <timeline-badge class="infos">
    </timeline-badge>
    <timeline-panel class="infos">
       <span class="time">
        {{event.hour}}
       </span>
     <div class="detail" ng-repeat="item in event.data">
      <span class="linename">{{item.customername}}</span>
      <div style="float: right;">
         <span class="linenum">
         {{item.reservenumber}}人
         </span>
      </div>

     </div>
    </timeline-panel>
   </timeline-event>
  </timeline>

 </ion-content>
</ion-view>

//controller
angular.module('studyapp.controllers')

 .controller('timelinectrl', function ($scope, $rootscope, $location) {
  $scope.title = '时间轴';

  makedata();

  function makedata() {
   $scope.teamdatalist=[

    {
     hour:"12:00",
     data:[
      {
       customername:"中国国旅(江苏)国际旅行社有限公司",
       reservenumber:"12",
       id:"aaaabbb12112"
      },
      {
       customername:"江苏2",
       reservenumber:"122",
       id:"aaaabbb12112"
      }
     ]
    },
    {
     hour:"13:00",
     data:[{
      customername:"江苏2",
      reservenumber:"112",
      id:"aaaabbb12112"
     }]

    },
    {
     hour:"14:00",
     data:[{
      customername:"江苏3",
      reservenumber:"12",
      id:"aaaabbb12112"
     }]

    },
    {
     hour:"13:00",
     data:[{
      customername:"江苏2",
      reservenumber:"112",
      id:"aaaabbb12112"
     }]

    },
    {
     hour:"14:00",
     data:[{
      customername:"江苏3",
      reservenumber:"12",
      id:"aaaabbb12112"
     }]

    }
   ];

  }

 });

四 效果图

angularjs实现时间轴效果的示例代码

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。