Angular 2.0 实现的搜索框
来源:互联网 发布:linux我的世界启动器 编辑:程序博客网 时间:2024/06/05 02:05
样式么。。。抄的bootstrap-table的搜索框
<style> .form-control { font-family: "Microsoft YaHei", Arial; font-size: 12px; width: 240px; border: 1px solid #dddddd; background: #ffffff; outline: none; box-shadow: none; padding: 6px 30px 6px 8px; } .search { height: 30px; width: 210px; background-color: #f6f6f6; border: 1px solid #f0f0f0; border-radius: 3px; padding-right: 30px; font-family: inherit; position: relative; height: 30px; width: 240px; float:right; margin: 0px; } .search span { position: absolute; width: 16px; height: 16px; top:6px; right: 10px; background: url("../images/icon_search_mirror.png") no-repeat right 0; cursor: pointer; }</style><div class="search"> <input class="form-control" type="text" #term (keyup)="search(term.value)" > <span></span></div>
然后实现
import { Component, EventEmitter, Input ,Output, OnInit } from '@angular/core';import { Subject } from 'rxjs/Subject';@Component({ moduleId: module.id, selector: 'search-directive', templateUrl:'search-directive.component.html'})export class SearchDirectiveComponent implements OnInit { @Input() placeholder:string; @Output() searchContent = new EventEmitter<Object>(); searchTermStream = new Subject<string>(); search(term:string) { this.searchTermStream.next(term); } getSearchStream() { let that = this; return that.searchTermStream .debounceTime(300) .distinctUntilChanged(); } ngOnInit() { let that = this; that.getSearchStream().subscribe((res)=> { this.searchContent.emit(res); }); }}使用的时候export组件,然后<search-directive (searchContent)="searchContentChange($event)"> </search-directive>
在JS代码中searchContentChange(data)处理用户在输入框输入的数据,默认的延时是300ms,开心~
0 0
- Angular 2.0 实现的搜索框
- Angular 2.0 中实现搜索框
- angular table的添加搜索
- angular利用$location实现搜索功能。
- angular的排序,敏感字符,添加,搜索
- 搜索框即时搜索的实现
- angular的路由实现,ngRoute
- angular实现的面板组件
- angular-ui-select 支持搜索的 下拉选择框 的使用
- angular 1.x checkbox复选框的实现(新增、编辑)
- 搜索框的实现JS
- iOS搜索框的实现
- 搜索框的js实现
- iOS搜索框的实现
- angular的弹出框
- angular-百度搜索
- angular 双向绑定的实现原理
- Angular实现的图书管理 demo
- Django数据库之一对一
- 人活着是为了什么--(反思 - 2016年10月27日)
- How-to create a Windows 10 usb installation media in Linux
- MapReduce学习(一)、(二)
- echarts-去掉X轴、Y轴和网格线
- Angular 2.0 实现的搜索框
- 前后台交互方法
- ansible第一次使用它的配置
- Linux下的常用命令(3.find)
- 2016秋季练习
- redis和memcached的区别
- 来自东东的第一贴
- va_list
- LeetCode[392. Is Subsequence] 难度[medium]