GithubHelp home page GithubHelp logo

marcopadillo / checklist-model Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vitalets/checklist-model

0.0 2.0 0.0 864 KB

AngularJS directive for list of checkboxes

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

License: MIT License

JavaScript 17.38% HTML 82.62%

checklist-model's Introduction

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.

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-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 = [] it is better to do checklistModelList.splice(0, checklistModelList.length) or wrap it in another object.
  • If you're using track by you must specify the same thing for checklist-value too. See #46.

Please, try out

Installation

  1. Download latest release or use bower bower install checklist-model or install from npm npm install checklist-model
  2. Add to app dependencies:
var app = angular.module("app", ["checklist-model"]);

How to get support

Please keep in mind to also create 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

We're using grunt as the build system. grunt jade generates the demo file and grunt server starts the demo server that can be access at http://localhost:8000. Tests can be ran by accessing http://localhost:8000/test.

The best way to involve is to report an issue/enhancement and then provide a pull request for it using Github usual features.

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 bower.json and package.json
  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

checklist-model's People

Contributors

beradrian avatar dotansimha avatar vitalets avatar sazo avatar cschroedl-gov avatar caseyn avatar marcopadillo avatar faheem-akhtar avatar guilleferrer avatar tomchentw avatar yiziz avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.