前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >AngularJS进阶(五)Angular实现下拉菜单多选

AngularJS进阶(五)Angular实现下拉菜单多选

作者头像
全栈程序员站长
发布2022-09-15 10:51:23
2.3K0
发布2022-09-15 10:51:23
举报
文章被收录于专栏:全栈程序员必看

大家好,又见面了,我是你们的朋友全栈君。

Angular实现下拉菜单多选

写这篇文章时,引用文章地址如下:

http://ngmodules.org/modules/angularjs-dropdown-multiselect

http://dotansimha.github.io/angularjs-dropdown-multiselect/#/

AngularJS Dropdown Multiselect

This directive gives you a Bootstrap Dropdown with the power of AngularJS directives.

Features

Based on Bootstrap’s dropdown.

jQuery is not necessary.

Seperated your data and the selection data. no modification to the data made.

Built-in search.

Complete control on the selected items model to fit it to your requirements.

Two view options: normal list and checkboxes.

Pre-selected values.

Limit selection count.

Grouping items by property.

Callback events.

Demo

http://dotansimha.github.io/angularjs-dropdown-multiselect/

Dependencies

required: AngularJS >= 1.2, Lodash >= 2, Bootstrap >= 3.0

Make sure to add the dependencies before the directive’s js file.

Note: Bootstrap JS file is not needed for the directive, it just uses the CSS file.

Install

Download the files

Using bower:

Just run bower install angularjs-dropdown-multiselect

Manually: You can download the .js file directly or clone this repository.

Include the file in your app

<script type=”text/javascript” src=”angularjs-dropdown-multiselect.js”></script>.

You can also use the minfined version (angularjs-dropdown-multiselect.min.js).

Include the module in angular (i.e. in app.js) – angularjs-dropdown-multiselect

Usage and Documentation

See the documentation and examples in the GitHub pages: http://dotansimha.github.io/angularjs-dropdown-multiselect/

由以上英文文档可以得知,若使用angularjs-dropdown-multiselect,首先需要在index.html中引入AngularJS >= 1.2, Lodash >= 2, Bootstrap >= 3.0,如下所示:

<script src=“js/angularjs-dropdown-multiselect.js”></script>

<script src=“js/lodash.min.js”></script>

并在app.js模块中添加依赖angularjs-dropdown-multiselect。如下所示:

var routerApp = angular.module(‘routerApp’, [‘ui.router’, ‘ngCookies’, ‘ngTable’, ‘angularjs-dropdown-multiselect’, ‘MedListModule’]);

yh_set_dtl.html核心代码如下:

<div style=”float:left“>优 惠 类 型:</div>

<!– Demo –>

<div ng-dropdown-multiselect=“”

options=“yhctlModelOptions”

selected-model=“yhctlModel”

checkboxes=“true”>

</div>

controllers.js代码如下:

$scope.yhctlModel = [];

$scope.yhctlModelOptions = [

{id: 1, label: ‘限定用户’},

{id: 2, label: “限定商家”},

{id: 3, label: “限定使用次数”},

{id: 4, label: “限定药品”},

{id: 5, label: “与其它优惠共享”}];

效果图如下:

AngularJS进阶(五)Angular实现下拉菜单多选
AngularJS进阶(五)Angular实现下拉菜单多选

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/164218.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

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

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

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

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Angular实现下拉菜单多选
    • Features
      • Demo
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档