npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-iselect

v1.2.3

Published

A simple and intuitive component for managing selections in lists within Angular. This component is compatible with Bootstrap.

Downloads

129

Readme

ngx-iselect

A simple and intuitive component for managing selections in lists within Angular. This component is compatible with Bootstrap.

Installation

npm i ngx-iselect.

Documentation

Inputs (Properties)

  • data (Array): The data to display.
  • mode (single | multiple)?: Determines if multiple values can be selected. The default mode is multiple.
  • type ( checkbox | radio) ?: Determines the type of the form check input. The default type is checkbox.
  • id (string): The id attribute of the objects.
  • label (string): The label to display.
  • selected (Array<string|number>) ?: If it’s in edit mode, this may have initial selected values. The default value is false.
  • isEdit ( boolean) ?: When isEdit is true, selected is required to check the initial selection.
  • useObject (boolean) ?: Determines if the returned selected values are objects or object attributes like id. The default value is false.

NB : Input values marked with ? are optional

Outputs (Properties)

  • Selected values

Usage

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

import { NgxIselectModule } from 'ngx-iselect'; // add this

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    NgxIselectModule  // add this
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
import { Component, ViewChild } from '@angular/core';
import { CommonModule } from '@angular/common';
import { NgxIselectComponent } from 'ngx-iselect';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'spring';
  @ViewChild('iselectComponent') iselectComponent!: NgxIselectComponent;
  selected_items: Array<any> = [];

  listOfObjects = [
    {
        id: 1,
        name: "Alice",
        age: 30,
        occupation: "Engineer"
    },
    {
        id: 2,
        name: "Bob",
        age: 25,
        occupation: "Designer"
    },
    {
        id: 3,
        name: "Charlie",
        age: 35,
        occupation: "Teacher"
    },
    {
        id: 4,
        name: "David",
        age: 28,
        occupation: "Developer"
    },
    {
        id: 5,
        name: "Eve",
        age: 22,
        occupation: "Student"
    }
];

constructor(){
  this.selected_items = [1,2]
}


// This will run when explicitly called (example : on button click)
showSelectedWithViewChild(){
  console.log("Showing select items with viewchild:", this.iselectComponent.selected_objects)
}

// This will run on each event
onSelectedChange(event: any){
  console.log("Showing select with event", event.selected)
}

}

NB: there are tow ways to access selected items from parents. Both can be used at same time:

  • onSelectedChange : to use each time selection change
  • ViewChild - used with template reference (example : #iselectComponent)

Example 1: Default values with onSelectedChange

 <ngx-iselect [data]="listOfObjects" [label]="'name'" [id]="'id'" (selectedChange)="onSelectedChange($event)"></ngx-iselect>

Example 2: Default values with ViewChild

When no need to perform action each time selection change

 <ngx-iselect #iselectComponent [data]="listOfObjects" [label]="'name'" [id]="'id'"></ngx-iselect>

 <button (click)="showSelectedWithViewChild()">Log selected elements</button>

Example 3

<ngx-iselect #iselectComponent [useObject]="true" [isEdit]="true" [data]="listOfObjects" [label]="'name'" [id]="'id'" [selected]="selected_items" [type]="'checkbox'" (selectedChange)="onSelectedChange($event)"></ngx-iselect>

<button (click)="showSelectedWithViewChild()">Log selected elements</button>

Example 4

<ngx-iselect #iselectComponent [useObject]="true" [isEdit]="true" [data]="listOfObjects" [label]="'name'" [id]="'id'" [selected]="selected_items" class="ngx-container" [type]="'checkbox'"></ngx-iselect>

<button (click)="showSelectedWithViewChild()">Log selected elements</button>

Display style(css)

ngx-iselect{
  display: flex;
}

Licence

This project is licensed under the MIT License.