Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

co-selectable-items

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

co-selectable-items

Selectable items component for Angular 2

  • 0.1.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by66.67%
Maintainers
1
Weekly downloads
 
Created
Source

co-selectable-items

This component can be used when you have a large list of items from which you wish to select a subset to be part of another list.

A typical situation would be selecting which user roles a specific user should have. Then there is a list of all roles available and a list for each user specifying which roles the user has.

The component is initialised with two lists: selectableItems, which is the list of all the items available plus a display name, and selectedItems, which is the selected subset of items.

When selecting and deselecting items, the selectedItems list is modified.

An example of user roles:

// The original items returning from the server could look like this:
var originalItems = [
  {
    role: 'admin'
  },
  {
    role: 'support'
  },
  {
    role: 'basic'
  }
]

// In order to use the list of items with this component you
// need to manually transform the list to have a displayName.
// The display name is the string shown to the user.
// (especially useful when needing i18n)
var selectableItems = [
  {
    {
      refValue: {
        role: 'admin'
      },
      displayName: 'Administrator'
    },
    {
      refValue: {
        role: 'support'
      },
      displayName: 'Customer Support'
    },
    {
      refValue: {
        role: 'basic'
      },
      displayName: 'Basic User'
    }
  }
]

// The list of selected items
var selectedItems = [
  {
    role: 'basic'
  },
  {
    role: 'support'
  }
]

Component HTML:

<co-selectable-items
  [selectable-items]="selectableItems"
  [selected-items]="selectedItems"
  [list-height]="'150px'">
</co-selectable-items>

Run the example code

  • npm install
  • npm start
  • navigate to localhost:3000 in web browser

FAQs

Package last updated on 12 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc