angularjs實(shí)現(xiàn)時(shí)間軸效果的示例代碼
一 引入包
引入angular-timeline包。
下載地址:angular-timeline.zip
在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中引用,不引用就沒(méi)有效果。

二 改寫(xiě)css
根據(jù)需求改寫(xiě)css,核心部分的改寫(xiě)。
可以寫(xiě)在style.css中,也可以新建一個(gè)css文件,但是一定要在index.html中引用。
/* 時(shí)間軸 */
.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;
}
三 頁(yè)面
準(zhǔn)備工作做完了,下面是頁(yè)面的編寫(xiě)。
<!--html頁(yè)面-->
<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 = '時(shí)間軸';
makeData();
function makeData() {
$scope.teamDataList=[
{
hour:"12:00",
data:[
{
customerName:"中國(guó)國(guó)旅(江蘇)國(guó)際旅行社有限公司",
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"
}]
}
];
}
});
四 效果圖

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
AngularJs html compiler詳解及示例代碼
本文主要介紹AngularJs html compiler的知識(shí)講解,這里整理了相關(guān)資料及相關(guān)示例代碼,有興趣的小伙伴可以參考下2016-09-09
Angular 2父子組件數(shù)據(jù)傳遞之@Input和@Output詳解(下)
這篇文章主要給大家介紹了關(guān)于Angular 2父子組件數(shù)據(jù)傳遞之@Input和@Output的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起看看吧。2017-07-07
深究AngularJS——ng-checked(回寫(xiě):帶真實(shí)案例代碼)
本篇文章主要介紹了深究AngularJS——ng-checked(回寫(xiě):帶真實(shí)案例代碼),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-06-06
Angular ng-animate和ng-cookies用法詳解
本文講一下Angular中動(dòng)畫(huà)應(yīng)用的部分。這篇文章主要介紹了Angular ng-animate和ng-cookies用法詳解,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-04-04
Angular基于Constructor?Parameter的依賴(lài)注入方式詳解
這篇文章主要為大家介紹了Angular基于Constructor?Parameter的依賴(lài)注入方式詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-11-11
使用AngularJS處理單選框和復(fù)選框的簡(jiǎn)單方法
這篇文章主要介紹了使用AngularJS處理單選框和復(fù)選框的方法,在AngularJS表單的基礎(chǔ)之上編寫(xiě)起來(lái)非常簡(jiǎn)單,需要的朋友可以參考下2015-06-06
Angular依賴(lài)注入optional?constructor?parameters概念
這篇文章主要為大家介紹了Angular?依賴(lài)注入領(lǐng)域里?optional?constructor?parameters?的概念及使用,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-11-11
AngularJS動(dòng)態(tài)生成div的ID源碼解析
這篇文章主要介紹了基于AngularJS動(dòng)態(tài)生成div的ID,本文介紹的非常詳細(xì),具有參考借鑒價(jià)值,對(duì)angularjs動(dòng)態(tài)生成div的id相關(guān)知識(shí)感興趣的朋友一起學(xué)習(xí)吧2016-08-08
AngualrJS中每次$http請(qǐng)求時(shí)的一個(gè)遮罩層Directive
AngularJS是一款非常強(qiáng)大的前端MVC框架。接下來(lái)通過(guò)本文給大家介紹AngualrJS中每次$http請(qǐng)求時(shí)的一個(gè)遮罩層Directive,本文非常具有參考借鑒價(jià)值,特此分享供大家學(xué)習(xí)2016-01-01

