前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ui-select官方教程(二)——ui-select指令

ui-select官方教程(二)——ui-select指令

作者头像
逝兮诚
发布2019-10-30 13:43:51
2.6K0
发布2019-10-30 13:43:51
举报
文章被收录于专栏:代码人生代码人生

ui-select指令

ui-select的指令和事件

属性

选项

描述

默认值

multiple

多选,直接加上multiple属性

close-on-select

在多选情况下,选中一项,就关闭下拉项

boolean

true

append-to-body

在多选情况下,选中项追加显示

boolean

false

ng-disabled

控件被禁用

boolean

true

ng-model

控件绑定对象

String,number,array

undefined

search-enabled

搜索功能

boolean

true

reset-search-input

选中一项后清楚搜索数据

boolean

true

theme

主题,有’bootstrap’、 ’select’、’select2’

String

bootstrap’

autofocus

加载时自动获得焦点

boolean

true

focus-on

定义一个监听事件的名字(e.g. focus-on='SomeEventName')

String

undefined

limit

限制多选择模式选择的项目数

integer

undefined

事件

事件名

描述

例子

on-remove

当项被删除时发生

on-remove="someFunction($item, $model)"

on-select

当项被选中时发生

on-select="someFunction($item, $model)"

全局配置

你可以使用全局配置来配置你的ui-select

代码语言:javascript
复制
app.config(function(uiSelectConfig) {uiSelectConfig.theme = 'bootstrap';
   uiSelectConfig.resetSearchInput = true;
uiSelectConfig.appendToBody= true; });

主题

ui-select有下列主题:

l bootstrap

l select2

l selectize

主题可以设置为全局配置

代码语言:javascript
复制
var app = angular.module('app',['ui.select']);
app.config(function(uiSelectConfig) {uiSelectConfig.theme = 'bootstrap'; });

或者在标签属性中设置,如:

代码语言:javascript
复制
<ui-selectng-model="animal.id" theme="bootstrap">    ...</ui-select>

添加引用

使用主题需要应用相应css

主题: bootstrap

文件:

代码语言:javascript
复制
<link rel="stylesheet"href="bower_components/bootstrap/dist/css/bootstrap.css">

或者使用less版本

CDN:

代码语言:javascript
复制
<link rel="stylesheet"href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.css">

配置

代码语言:javascript
复制
app.config(function(uiSelectConfig){uiSelectConfig.theme='bootstrap';});

主题: select2

文件:

版本select2~3.4.5

代码语言:javascript
复制
<link rel="stylesheet"href="bower_components/select2/select2.css">

CDN:

代码语言:javascript
复制
<link rel="stylesheet"href="http://cdnjs.cloudflare.com/ajax/libs/select2/3.4.5/select2.css">

配置

代码语言:javascript
复制
app.config(function(uiSelectConfig){uiSelectConfig.theme='select2';});

主题: selectize

文件:

版本selectize~0.8.5

代码语言:javascript
复制
<link rel="stylesheet"href="bower_components/selectize/dist/css/selectize.default.css">

或者使用less版本

CDN:

代码语言:javascript
复制
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.8.5/css/selectize.default.css">

配置

代码语言:javascript
复制
app.config(function(uiSelectConfig){uiSelectConfig.theme='selectize';});
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017-07-07 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • ui-select指令
    • 属性
      • 事件
        • 全局配置
          • 主题
            • 添加引用
            相关产品与服务
            内容分发网络 CDN
            内容分发网络(Content Delivery Network,CDN)通过将站点内容发布至遍布全球的海量加速节点,使其用户可就近获取所需内容,避免因网络拥堵、跨运营商、跨地域、跨境等因素带来的网络不稳定、访问延迟高等问题,有效提升下载速度、降低响应时间,提供流畅的用户体验。
            领券
            问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档