• Stars
    star
    1,051
  • Rank 43,859 (Top 0.9 %)
  • Language
    HTML
  • License
    MIT License
  • Created about 11 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

AngularJS directive for list of checkboxes

Bower NPM License

NPM

checklist-model

AngularJS directive for list of checkboxes

Why this is needed?

In Angular one checkbox <input type="checkbox" ng-model="..."> is linked with one model.
But in practice we usually want one model to store array of checked values from several checkboxes.
Checklist-model solves that task without additional code in controller.

Live demo

http://vitalets.github.io/checklist-model

Installation

Note: since version 1.0.0 you must install the angular library yourself as it is now a peerDependency

  1. Download package:
    • From npm npm install checklist-model
    • From bower bower install checklist-model
    • From latest release
  2. Include script to the HTML:
    <script src='checklist-model.js'></script>
  3. Add to app dependencies:
    var app = angular.module("app", ["checklist-model"]);

Usage

You should play with attributes of <input> tag:

Attribute Mandatory Description
checklist-model Yes Use instead of ng-model
checklist-value No What should be picked as array item
value No What should be picked as item, but unlike checklist-value, this does not evaluate as an angular expression, but rather a static value
ng-model No Every checkbok will span a new scope and define a variable named checked to hold its state. You can modify this name by using this attribute.
checklist-comparator No A custom comparator. If it starts with dot(.) then it will be an expression applied to the array item. Otherwise it should evaluate to a function as an angular expression. The function return true if the first two arguments are equal and false otherwise.
checklist-before-change No An angular expression evaluated each time before the checklist-model has changed. If it evaluates to 'false' then the model will not change anymore.
checklist-change No An angular expression evaluated each time the checklist-model has changed.
  • If you modify directly the value of the checklist-model, it is possible that the UI won't be updated. This is because this directive looks for the model in the parent, not in the current scope. Instead of doing checklistModelList = [] you should do checklistModelList.splice(0, checklistModelList.length) or wrap it in another object. Consequently, instead of doing checklistModelList = angular.copy(allValues) you should do checklistModelList.push.apply(checklistModelList, allValues). The idea is to use the same array and not replace it with a new one.
  • If you're using track by you must specify the same thing for checklist-value too. See #46.
  • If you're also using ngModel, please keep in mind that the state of the checkbok is initialized with the value from checklistModel, not with the one from ngModel. Afterwards the two will be kept in sync, but initially, these two can be conflicting, so only checklistModel is used. See the entire discussion at #104.

Examples

How to get support

Please keep in mind to also add a Plunkr or JSFiddle example. This will greatly help us in assisting you and you can use one of the existing examples and fork it.

Development

How to run tests

  1. Generate live demo index.html via grunt jade
  2. Run local http server grunt server
  3. Open in browser http://localhost:8000 to check that demo is accessible
  4. Open in browser http://localhost:8000/test and wait until all tests pass

How to add a new test case

  1. Create a new folder under docs/blocks named your-test.
  2. Create under that folder ctrl.js to describe the test Angular controller, view.html to describe the view part in HTML and test.js for the Angular scenario test. You can use an existing test as an example.
  3. Add a line like - items.push({id: 'your-test', text: 'Your test, ctrlName: 'CtrlTestName', testValue: 'selectedItems'}) to docs/index.jade
  4. Add a line like <script src="../docs/blocks/your-test/test.js"></script> to test\index.html
  5. Run grunt jade to generate index.html from docs/index.jade
  6. Run grunt server
  7. Access http://localhost:8000 for samples and http://localhost:8000/test for running the tests.

How to make a new release

  1. Change the version number in package.json, bower.json and checklist-model.nuspec (if not already changed - check the version number against the latest release in Github)
  2. Create a new release in github with the same name for tag and title as the version number (e.g. 1.0.0). Do not forget to include the changelog in the release description.
  3. Run npm publish to publish the new version to npm

License

MIT

More Repositories

1

x-editable

In-place editing with Twitter Bootstrap, jQuery UI or pure jQuery
JavaScript
6,477
star
2

react-native-extended-stylesheet

Extended StyleSheets for React Native
JavaScript
2,926
star
3

github-trending-repos

Track GitHub trending repositories in your favorite programming language by native GitHub notifications!
HTML
2,678
star
4

angular-xeditable

Edit in place for AngularJS
HTML
1,913
star
5

awesome-smart-tv

⚡A curated list of awesome resources for building Smart TV apps
1,072
star
6

websocket-as-promised

A Promise-based API for WebSockets
JavaScript
595
star
7

bootstrap-editable

This plugin no longer supported! Please use x-editable instead!
JavaScript
558
star
8

await-timeout

A Promise-based API for setTimeout / clearTimeout
JavaScript
428
star
9

playwright-bdd

BDD testing with Playwright runner
TypeScript
302
star
10

combodate

Dropdown date and time picker
JavaScript
208
star
11

autotester

Chrome extension that allows to develop and run automation tests right in browser
JavaScript
170
star
12

clockface

Clockface timepicker for Twitter Bootstrap
CSS
168
star
13

awesome-browser-extensions-and-apps

⚡A curated list of awesome resources for building browser extensions and apps
126
star
14

babel-plugin-runtyper

⚡️ Runtime type-checker for JavaScript
JavaScript
116
star
15

x-editable-yii

Yii extension for creating editable elements
JavaScript
112
star
16

docker-tizen-webos-sdk

Docker image with Samsung Tizen CLI and LG webOS CLI
Dockerfile
94
star
17

tinkoff-invest-api

Node.js SDK для работы с Tinkoff Invest API
HTML
44
star
18

bro-fs

Promise-based HTML5 Filesystem API similar to Node.js fs module
JavaScript
43
star
19

yii-bootstrap-editable

Yii extension for Bootstrap-editable plugin
JavaScript
31
star
20

alice-renderer

Node.js библиотека для формирования ответов в навыках Яндекс Алисы.
JavaScript
30
star
21

playwright-bdd-example

Example project that uses playwright-bdd to run BDD tests
TypeScript
30
star
22

playwright-magic-steps

Auto-transform JavaScript comments into Playwright steps
TypeScript
29
star
23

alice-workshop

Воркшоп по разработке навыка для Алисы на Node.js
JavaScript
28
star
24

js-testrunners-bench

JavaScript test-runners benchmark
JavaScript
27
star
25

groupgridview

Yii extension to group data in your grid
PHP
24
star
26

lazy-model

AngularJS directive that works like `ng-model` but accept changes only when form is submitted (otherwise changes are cancelled)
JavaScript
21
star
27

tinkoff-robot

Пример торгового робота для Tinkoff Invest API (Node.js)
TypeScript
21
star
28

chnl

JavaScript event channels compatible with Chrome extensions API
JavaScript
19
star
29

docker-stack-wait-deploy

A script waiting for docker stack deploy command to complete.
Shell
18
star
30

playwright-network-cache

Cache and mock network requests in Playwright
TypeScript
17
star
31

alice-tester

Библиотека для автоматического тестирования навыков Алисы на Node.js.
JavaScript
14
star
32

promise-controller

Advanced control of JavaScript promises
JavaScript
13
star
33

controlled-promise

Advanced control of JavaScript promises
JavaScript
13
star
34

mocha-es6-modules

Running Mocha tests in the browser with ES6 Modules support
JavaScript
12
star
35

yandex-cloud-deploy-fn

CLI для деплоя функций в Yandex Cloud на Node.js
TypeScript
11
star
36

tinkoff-local-broker

Локальный сервер для тестирования торговых роботов на Tinkoff Invest API
TypeScript
9
star
37

alice-cloud-proxy

Готовая облачная функция для развертывания своего прокси-навыка для Алисы
JavaScript
9
star
38

throw-utils

Helpers for error throwing
TypeScript
5
star
39

wait-for-cmd

A pure shell script waiting for provided command to exit with zero code
Shell
5
star
40

selgridview

Yii extension to keep selected rows in CGridView when sorting and pagination
JavaScript
5
star
41

alice-protocol

JSON схемы запросов и ответов в навыках Алисы
JavaScript
5
star
42

alice-skill-starter

Быстрый старт навыка для Алисы на Node.js
JavaScript
5
star
43

ydb-sdk-lite

Lightweight implementation of Yandex Database SDK for Node.js
JavaScript
4
star
44

flat-options

One-level options with default values and validation
JavaScript
4
star
45

yandex-cloud-fn

Хелперы для функций в Yandex Cloud (Node.js)
TypeScript
4
star
46

alice-testing-example

Пример функционального тестирования навыка для Яндекс Алисы на Node.js.
JavaScript
4
star
47

page-object

A Page Object pattern implementation library for JavaScript
JavaScript
4
star
48

yc-serverless-live-debug-original

Live debug of Yandex cloud functions with local code on Node.js
TypeScript
4
star
49

eslint-plugin-visual-complexity

Enforce a visual complexity of the code
JavaScript
4
star
50

npxd

Run NPX commands inside Docker container
Shell
3
star
51

fetchers

Semantic RESTful Fetch API wrappers
JavaScript
3
star
52

early-errors

A tiny script to catch webpage errors earlier.
JavaScript
3
star
53

json-micro-schema

Minimal JSON schema validation format
JavaScript
3
star
54

loggee

Zero-dependency JavaScript logger with namespaces
JavaScript
3
star
55

selenium-fileserver

Public website serving Selenium self-test static pages
JavaScript
2
star
56

alice-types

Тайпинги для протокола Алисы.
TypeScript
2
star
57

marusya-types

Тайпинги для протокола Маруси.
TypeScript
2
star
58

micro-schema

JavaScript implementation of json-micro-schema validation format
JavaScript
2
star
59

sheeva

Concurrent Automation Test Runner
JavaScript
2
star
60

subpath-imports-typescript

Example of TypeScript project with Subpath Imports
TypeScript
2
star
61

uni-skill

Универсальный интерфейс для разработки навыков голосовых ассистентов.
TypeScript
2
star
62

alice-asset-manager

Node.js API для загрузки изображений и звуков в навык Алисы.
JavaScript
2
star
63

pendings

[DEPRECATED] Better control of promises
JavaScript
2
star
64

playwright-webhook-reporter

Universal Playwright reporter to send test results to any webhook
JavaScript
1
star
65

react-server-actions-jsx

Example Next.js app with server actions returning JSX
TypeScript
1
star
66

skill-afisha-moscow

TypeScript
1
star
67

qrlink

HTML
1
star
68

promised-map

A map of promises that can be resolved or rejected by key
TypeScript
1
star
69

json-paths

Collect different paths of JSON data.
TypeScript
1
star
70

yandex-cloud-fn-internals

Roff
1
star
71

retry

Retry async function with exponential delay, timeouts and abort signals
TypeScript
1
star
72

alice-dev

Инструменты разработчика для навыков Алисы
JavaScript
1
star
73

skill-dev-proxy

Навык для Алисы, позволяющий отлаживать другие навыки прямо на устройстве
TypeScript
1
star
74

logger

Pure typescript logger with levels and prefix support
TypeScript
1
star
75

yandex-cloud-lite

Минимальный Node.js клиент для доступа к API сервисов Yandex Cloud по GRPC
JavaScript
1
star