/* ---html----*/

<ion-searchbar [(ngModel)]="searchQuery" (input)="getItems($event)"></ion-searchbar>
<ion-list>
<ion-item *ngFor="#item of items">
{{ item }}
</ion-item>
</ion-list> /* ---html----*/
/* ---js----*/

import {Page} from 'ionic-angular';

@Page({
templateUrl: 'build/pages/tabs/tabs.html',
}) export class TabsPage { constructor() {
this.searchQuery = '';
this.initializeItems();
} initializeItems() {
this.items = [
'Amsterdam',
'Bogota',
];
} getItems(searchbar) {
//给作用域 items 一个默认值。
this.initializeItems();
//获取文本框里的 value
var q = searchbar.value; //如果值是空字符串,则不过滤项目
if (q.trim() == '') {
return;
}
//否则 过滤一下 this.items
this.items = this.items.filter((v) => {
if (v.toLowerCase().indexOf(q.toLowerCase()) > -1) {
return true;
}
return false;
})
} } /* ---js----*/

还有更多的样式http://ionicframework.com/docs/v2/api/components/searchbar/Searchbar/

9、搜索 :ion-searchbar的更多相关文章

  1. 猫猫学iOS 之微博项目实战(5)微博自己定义搜索框searchBar

    猫猫分享.必须精品 原创文章.欢迎转载. 转载请注明:翟乃玉的博客 地址:http://blog.csdn.net/u013357243 一:效果 用UITextField简单定义一个搜索框 二:调用 ...

  2. AJ学IOS 之微博项目实战(5)微博自定义搜索框searchBar

    AJ分享,必须精品 一:效果 用UITextField简单定义一个搜索框 二:调用: 调用的代码,很简单,直接init就可以,以后加功能自己添加就行了. - (void)viewDidLoad { [ ...

  3. 【IOS开发】搜索和排序(好友列表,通讯录的实现,searchbar)

    一.效果图: 二.概述 实现一个好友列表,可以分为男女两个选项,并且实现搜索和排序功能.我的数据是放在plist文件中. 三.代码简述 代码结构如图,首先自定义一个Cell. cell.h #impo ...

  4. iOS--- UITableView + UISearchDisplayController - - - - -实现搜索功能

    iOS中UISearchDisplayController用于搜索,搜索栏的重要性我们就不说了,狼厂就是靠搜索起家的,现在越来越像一匹没有节操的狼,UC浏览器搜索栏现在默认自家的神马搜索,现在不管是社 ...

  5. searchBar控件

    那就先了解一下UISearchBar控件吧! UISearchBar控件就是要为你完成搜索功能的一个专用控件.它集成了很多你意想不到的功能和特点! 首先,还是来普及一下UISearchBar控件API ...

  6. searchbar的使用介绍

    searchBar的使用介绍 首先如何创建一个SearchBar实例: self.searchBar = [[UISearchBar alloc] initWithFrame: CGRectMake( ...

  7. iOS开发UI篇 -- UISearchBar 属性、方法详解及应用(自定义搜索框样式)

    很多APP都会涉及到搜索框,苹果也为我们提供了默认的搜索框UISearchBar.但实际项目中我们通常需要更改系统默认搜索框的样式.为了实现这一目标,我们需要先搞懂 UISearchBar 的属性及方 ...

  8. ios UISearchDisplayController 实现 UITableView 搜索功能

    UISearchDisplayController 是苹果专为 UITableView 搜索封装的一个类. 里面内置了一个 UITableView 用于显示搜索的结果.它可以和一个需要搜索功能的 co ...

  9. UISearchBar去掉SearchBar上面两条分割线

    设置之前: 设置之后: 代码如下: // // ViewController.m // UISearchBarDemo // // Created by 思 彭 on 17/3/24. // Copy ...

  10. iOS 搜索条使用详解

    在ios开发中搜索条的使用挺常见的,不过之前一直没用到也没细细研究,最近做外包项目的时候刚好用到,在这里记录一下使用的过程,只要理解了原理,其实还是比较简单的!上传的图片有点大,刚好可以看清楚它的使用 ...

随机推荐

  1. newman的常用命令使用总结

    前提:为了运行newman,你要确保系统中安装的Node.js版本是大于v6的. 命令常用选项: newman [optiions] -h:显示命令行帮助,包括选项列表和简单的使用案例. -v:显示当 ...

  2. luoguP3415 祭坛

    https://www.luogu.org/problemnew/show/P3415 考虑二分结界层数,将 n 个点按 x 大小依次加入答案,一行一行的做,用树状数组维护当前这一行中[0, x - ...

  3. linux操作之文本编辑器

    1.文本编辑器的作用 编辑和修改系统中的那些以文本形式存在的文件(特别是各种配置文件),也可以用于 编写程序代码 2.linux下的常见编辑器 nano.Emacs.gedit.vim等 3.vim三 ...

  4. The server of Apache (三)——网页优化

    在企业中,部署apache后只采用默认的配置参数,会有很多问题,因为那些配置都是针对以前服务器配置的. 一.网页压缩 1.介绍 配置apache的网页压缩功能,是使用Gzip压缩算法来对apache服 ...

  5. MongDB from execCommand not master

    count failed: not master{ , "errmsg" : "not master" } at src/mongo/shell/query.j ...

  6. web 服务器安全防范

    apache 关闭目录 配置文件:安装目录/Apache/conf/httpd.conf <Directory /> #默认就会把/ 的目录暴漏出来:关闭方法: Options -Inde ...

  7. ABP项目后台初始化数据库

    设置host为启动项,并修改连接字符串 在程序包管理控制台中,默认项目选中EFCore 执行Update-Database命令

  8. A. Little C Loves 3 I Codeforces Round #511 (Div. 2) 【数学】

    题目: Little C loves number «3» very much. He loves all things about it. Now he has a positive integer ...

  9. C++ STL之Set

    set是关联容器,类似于集合. 特点是里面的元素不会重复,而且元素时有序的. 1.声明定义: #include<set> using namespace std; set<int&g ...

  10. 面向对象中的@classonlymethod 与 @classmethod的区别

    如果要使用classonlymethod ,则需要先定义好一个classonlymethod 类. 首先我们需要明白无论是classonlymethod还是classmethod,本质都是一个类,而c ...