1.效果图

 

2.controller .js

 .controller("ProductCtrl", function ($scope,$ionicModal,$ionicScrollDelegate,$ionicSlideBoxDelegate,Storage, $state,$ionicLoading) {

      $scope.ProductListData=[
{id:0,title:'推荐'},
{id:1,title:'热点'},
{id:2,title:'视频'},
{id:3,title:'体育'},
{id:4,title:'社会'},
{id:5,title:'娱乐'},
{id:6,title:'图片'},
{id:7,title:'军事'},
]; $scope.categoryListOtherData= [
{id:1,title:'行尸走肉'},
{id:2,title:'金蝉脱壳'},
{id:3,title:'百里挑一'},
{id:4,title:'天上人间'},
{id:5,title:'不吐不快'}
];
$scope.categoryListMyData=[
{id:6,title:'金玉满堂'},
{id:7,title:'背水一战'},
{id:8,title:'霸王别姬'},
{id:9,title:'海阔天空'},
{id:10,title:'情非得已'}
];
$ionicModal.fromTemplateUrl('templates/category.html', {
scope: $scope
}).then(function(modal) {
$scope.categoryModal = modal;
}); $scope.openCategoryModal = function() { $scope.categoryModal.show();
};
$scope.closeCategoryModal = function() {
$scope.categoryModal.hide();
}; $scope.is_close=false;
var w=window.innerWidth //获取屏幕的宽度
|| document.documentElement.clientWidth
|| document.body.clientWidth; $scope.subTitle="";
$scope.changeTab=function(id){
angular.forEach($scope.ProductListData, function (data ,index,arry) {
}
);
angular.forEach($scope.ProductListData, function (data ,index,arry) {
if(data.id==id){
$scope.subTitle=data.title;
document.getElementById("but_"+id).className="button button-clear activebutton";
}else{
document.getElementById("but_"+data.id).className="button button-clear";
}
})
} $scope.deltab=function(id){
delorAdditem($scope.categoryListMyData,id,$scope.categoryListOtherData)
}
$scope.addtab=function(id){
delorAdditem($scope.categoryListOtherData,id,$scope.categoryListMyData)
}
var all_cate_width=8; //定义默认的导航数量
all_cate_width=$scope.categoryListMyData.length;
$scope.all_cate_width=all_cate_width*30+'%'; var delorAdditem =function(objarry ,id,targetarry){
angular.forEach(objarry, function (data,index,arry) {
if(data.id==id){
targetarry.push(data);
objarry.splice(index,1);
}
})
}
});

3.html

<ion-view title="新闻资讯">
<ion-nav-buttons side="left">
<button menu-toggle="left" class="button button-icon icon ion-navicon"></button>
</ion-nav-buttons>
<div class="bar bar-subheader">
<ion-scroll direction="x" scrollbar-x="false" delegate-handle="s_header" style="width: 100%;margin-right: 5px;">
<div class="button-bar sub_header_catgorylist" id="sub_header_list" style="width:{{all_cate_width}}; ">
<a ng-repeat="r in ProductListData" ng-click="changeTab(r.id)" id="but_{{r.id}}" class="button button-clear">{{r.title}}</a>
</div>
</ion-scroll>
<div class="ion-plus subheader_r_icon" ng-click="openCategoryModal($event);"></div>
</div>
<ion-content class="has-subheader">
<div>
<h1>{{subTitle}}</h1>
</div>
</ion-content>
</ion-view>
<div class="modal">
<ion-header-bar class="bar-positive">
<h1 class="title">我的频道</h1>
<div class="buttons">
<i class="icon ion-ios-close-empty" ng-click="closeCategoryModal()"
style="width: 36px; height: 36px; line-height: 36px; text-align: center; font-size: 34px;" />
</div>
</ion-header-bar>
<ion-content class="category-content"> <div class="category_title">
我的频道
<span ng-if="!is_close">(点击删除频道)</span>
</div>
<div class="category_list">
<ion-list ng-class="{'ion_list_no_rorder':!is_close}" >
<div ng-if="!is_close">
<ion-item ng-repeat="(key,cate) in categoryListMyData" on-tap="cateChangeTab(cate.id,key)" >
{{cate.title}}
<div class="float_icon" ng-click="deltab(cate.id)"></div>
<ion-delete-button class="ion-minus-circled" ></ion-delete-button>
<ion-reorder-button class="ion-navicon" on-reorder="move_item(item,$fromIndex,$toIndex)"></ion-reorder-button>
</ion-item>
</div>
</ion-list>
</div>
<div ng-if="!is_close" class="category_title">
点击添加到我的频道
</div>
<div ng-if="!is_close" class="category_list">
<ul>
<li ng-repeat="(key,cate) in categoryListOtherData" on-tap="addtab(cate.id)">
<a href="javascript:void(0);">{{cate.title}}</a>
</li>
</ul>
</div>
</ion-content>
</div>

4.css

body, .ionic-body{font-family: 微软雅黑, Arial, Helvetica, sans-serif;}

.bar .sub_header_list .button.button-clear{

  border-bottom: 1px solid #eee;
}
.sub_header_list .button{
width: 50%;
color:#666;
}
.bar .sub_header_list .button.sub_button_select{
border-bottom:2px solid #387ef5;
position:relative;
}
.bar-subheader{
border-bottom: none;
}
.red{
color:red;
} .comm button{height:32px !important;width:100%;font-size:12px !important;color:#1DACE3 !important;}
.subheader_r_icon{
position: absolute;
right: 0px;
width: 26px;
height: 36px;
line-height: 38px;
top: 0px;
text-align: center;
background: #fff;
color:#666;
}
.sub_header_catgorylist .button{
width: 25%;
color:#8f8f8f;
}
.sub_header_catgorylist .activebutton{
color:#ff3b30;
padding:0 16px;
}
/********************************类别样式***************************************************/
.category-content .category_title{ padding-top: 8px;
padding-bottom: 8px;
color: #666;
padding-left: 3.4%;
padding-right: 3.4%;
background: #eee;
} .category-content .category_title .button{ min-height: 20px;
line-height: 20px; }
.category-content .category_list ul li{
height: 36px;
line-height: 36px;
border-color: #b2b2b2;
background-color: #f8f8f8;
color: #444;
display: inline-block;
border-width: 1px;
border-style: solid;
border-radius: 6px;
vertical-align: top;
text-align: center;
text-overflow: ellipsis;
font-size: 14px;
cursor: pointer;
width: 20%;
margin-top: 10px;
margin-bottom: 10px;
margin-left: 3.4%;
position: relative;
}
.category-content .category_list ul li a{
text-decoration:none;
color: #444;
}
.category-content .category_list ul li .close{
position: absolute;
left: -5px;
top: -5px;
width: 12px;
height: 12px;
line-height: 12px;
border-radius: 12px;
color: #fff;
background: #222222;
font-size: 12px;
} .category-content .category_list .ion_list_no_rorder ion-item{
height: 36px;
line-height: 36px;
border-color: #b2b2b2;
background-color: #f8f8f8;
color: #444;
display: inline-block;
border-width: 1px;
border-style: solid;
border-radius: 6px;
vertical-align: top;
text-align: center;
text-overflow: ellipsis;
font-size: 14px;
cursor: pointer;
width: 20%;
margin-top: 10px;
margin-bottom: 10px;
margin-left: 3.4%;
position: relative;
}
.category-content .category_list .ion_list_no_rorder ion-item a{
text-decoration:none;
color: #444;
} .category-content .category_list .ion_list_no_rorder ion-item .close{
position: absolute;
left: -5px;
top: -5px;
width: 12px;
height: 12px;
line-height: 12px;
border-radius: 12px;
color: #fff;
background: #222222;
font-size: 12px; }
.ion_list_no_rorder .item-complex .item-content,.ion_list_no_rorder .item-radio .item-content{
padding: 0px;
} .float_icon{
position:absolute;
width:16px;
height: 16px;
border: 0px solid #6b46e5;
float:right;
z-index:;
right:;/* 定位到右上 */
top:;
background-image: url('../img/sc.png');
} /********************************类别样式***************************************************/

5.如果无法用手指滚动,需要配置app   config 配置:

$ionicConfigProvider.scrolling.jsScrolling(true);  1.2++之后都向原生方向发展,所有没有滚动了

Ionic 新闻类别菜单的更多相关文章

  1. [转]教你一招 - 如何给nopcommerce增加新闻类别模块

    本文转自:http://www.nopchina.net/post/nopchina-teach-newscategory.html nopcommerce的新闻模块一直都没有新闻类别,但是很多情况下 ...

  2. sql查询统计,根据新闻类别ID统计,没有数据显示0

    有两张表,新闻信息表MessageInfo和新闻类别表MessageType.表结构如下: 然后需要实现下面这种查询结果: 这个是我面试时遇到的,上面的新闻类型是乱写的.当时没有做出来,然后回来又研究 ...

  3. 案例19-页面使用ajax显示类别菜单

    1 版本一 版本只能在首页显示类别,当切换到了其它页面就不会显示 1 web层IndexServlet代码 package www.test.web.servlet; import java.io.I ...

  4. ionic-Javascript:ionic 上拉菜单(ActionSheet)

    ylbtech-ionic-Javascript:ionic 上拉菜单(ActionSheet) 1.返回顶部 1. ionic 上拉菜单(ActionSheet) 上拉菜单(ActionSheet) ...

  5. ionic第二坑——ionic 上拉菜单(ActionSheet)安卓样式坑

    闲话不说,先上图: 这是IOS上的显示效果,代码如下: HTML部分: <body ng-app="starter" ng-controller="actionsh ...

  6. 利用jquery实现百度新闻导航菜单滑动动画

    前言 前两天,群里有人问百度新闻导航是如何实现的,当时由于忙于工作,没有来得及细看,恰好今天有空闲时间,索性就实现一下这个效果吧: 思路与步骤 1.利用UL创建简单横向导航: <!DOCTYPE ...

  7. ionic 侧栏菜单用法

    第一步: 引入js和css文件我这里是直接引入的cdn,ionic是基于angular的,bundle.min.js把常用angular的js已经压缩到一起,可以直接引入.bundle.min.js, ...

  8. 【Web】利用jquery实现百度新闻导航菜单滑动动画

    前言 前两天,群里有人问百度新闻导航是如何实现的,当时由于忙于工作,没有来得及细看,恰好今天有空闲时间,索性就实现一下这个效果吧: 思路与步骤 1.利用UL创建简单横向导航: <!DOCTYPE ...

  9. ionic 上拉菜单(ActionSheet)安装和iOS样式不一样

    ISO中的界面是这样的: 然而,Android中的界面是这样的: 代码如下: HTML部分: <body ng-app="starter" ng-controller=&qu ...

随机推荐

  1. JavaScript 点击事件的三种写法

    嵌入式 <button οnclick='alert("hello")'>点击按钮</button> 脚本模型 btn.onclick=function() ...

  2. 0704 Process继承实现多进程、Pool进程池,进程间通过队列通信,Pool实现多进程实现复制文件

    通过继承的方式,实现Process多进程 from multiprocessing import Process import time class MyNewProcess(Process): de ...

  3. js--判断当前环境是否为iphonex环境

    /** * 判断是否是iphonex */ function getIsIphonex () { var u = navigator.userAgent; var isIOS = !!u.match( ...

  4. (转)Android中RelativeLayout各个属性的含义

    转:http://blog.csdn.net/softkexin/article/details/5933589 android:layout_above="@id/xxx"  - ...

  5. C++函数调用原理理解

    空程序: int main() { 00411360  push        ebp       ;压入ebp 00411361  mov         ebp,esp     ;ebp = es ...

  6. Hadoop 平台搭建

    一.在Linux中安装JDK并配置环境变量 输入javac 查看是否已安装java环境如果没有安装 sudo apt-get install openjdk-7-jdk再次检测 javac修改配置参数 ...

  7. 云-腾讯云-云直播:云直播(LVB)

    ylbtech-云-腾讯云-云直播:云直播(LVB) 云直播(Live Video Broadcasting,LVB)依托腾讯多年的音视频技术平台,以及全球海量加速节点和领先的音视频 AI 技术,为开 ...

  8. SpringBoot--Banner的定制和关闭

    SpringBoot项目启动的时候控制台会打印如下信息: 上面红色框框内的“SPRING BOOT”被称为Banner,意为横幅,默认会开启并在控制台打印,其实我们可以修改它的内容和样式,即定制:并选 ...

  9. 02.万恶之源-python 运算符和编码

    一.流程控制语句if: 第一种语法: (最基本的语法) if 条件: 代码块/结果1 结果2 # 如果条件是真(True)执行结果为1,然后结果为2,如果条件为错(False), 直接结果2. 第二种 ...

  10. 用户管理模块之mysql.user

    不使用-h参数来指定登录host,默认会连接localhost,仅当mysql.user表中有一条对应的localhost访问授权(username@%不对任何主机做限制也不行)时登录才成功,否则登录 ...