Coder Social home page Coder Social logo

hsuanxyz / ionic-tags-input Goto Github PK

View Code? Open in Web Editor NEW
71.0 5.0 25.0 208 KB

A ionic tags input component

Home Page: https://stackblitz.com/edit/ionic-tags-input

License: MIT License

TypeScript 55.28% HTML 15.67% CSS 19.96% JavaScript 9.09%
ionic ionic-tags tags-input tagsinput ionic2

ionic-tags-input's Introduction

ionic-tags-input

Dependency Status NPM version Downloads MIT License

NPM

A ionic tags input component for ionic2 中文文档

demo

DEMO

Install

npm install ionic-tags-input --save

Use

import the module:

...
import {IonTagsInputModule} from "ionic-tags-input";

@NgModule({
 ...
 imports: [
   IonTagsInputModule,
   ...
 ],
 ...
})
export class AppModule {}

Example

Basic

<ion-tags-input [(ngModel)]="tags" (onChange)="onChange($event)"></ion-tags-input>
export class YourPage {

  tags = ['Ionic', 'Angular', 'TypeScript'];

  constructor() {}

  onChange(val){
    console.log(tags)
  }

}

set placeholder

<ion-tags-input [(ngModel)]="tags" [placeholder]="'add tag'"></ion-tags-input>

set input type

*** Can not be verified, but can set the keyboard type ***

<ion-tags-input [(ngModel)]="tags" [type]="'email'"></ion-tags-input>

can not be repeated

<ion-tags-input [(ngModel)]="tags" [once]="'true'"></ion-tags-input>

Style

Setting mode

<ion-tags-input [(ngModel)]="tags" [mode]="'md'"></ion-tags-input>
<ion-tags-input [(ngModel)]="tags" [mode]="'ios'"></ion-tags-input>
<ion-tags-input [(ngModel)]="tags" [mode]="'wp'"></ion-tags-input>

Setting color:

<ion-tags-input [(ngModel)]="tags" [color]="'light'"></ion-tags-input>
<ion-tags-input [(ngModel)]="tags" [color]="'secondary'"></ion-tags-input>
<ion-tags-input [(ngModel)]="tags" [color]="'danger'"></ion-tags-input>

All color: light secondary danger dark warn gray purple

Special color: random

Hide remove button

<ion-tags-input [(ngModel)]="tags" [hideRemove]="true"></ion-tags-input>

Separator

Use separator submit input

<ion-tags-input [(ngModel)]="tags" [separatorStr]="','"></ion-tags-input>

Keyboard

Use Backspace remove tag

<ion-tags-input [(ngModel)]="tags" [canBackspaceRemove]="true"></ion-tags-input>

Use Enter submit input

<ion-tags-input [(ngModel)]="tags" [canEnterAdd]="true"></ion-tags-input>

Verify

A function whose argument is a string, returns a boolean value

<ion-tags-input [(ngModel)]="tags" [verifyMethod]="verifyTag"></ion-tags-input>
export class YourPage {

  tags = ['Ionic', 'Angular', 'TypeScript'];

  constructor() {}

  verifyTag(str: string): boolean{
    return str !== 'ABC' && str.trim() !== '';
  }

}

API

Input

Name Type Description
mode String platform style md ios wp
color String color style light secondary danger dark warn gray purple random #xxxxxx
readonly Boolean readonly
placeholder String input placeholder
type String input type
maxTags number sets tags max number, -1 unlimited
hideRemove Boolean hide remove button
once Boolean setting can not be repeated
canEnterAdd Boolean can usr the Enter key submit input
canBackspaceRemove Boolean can usr the Backspace key remove tag
verifyMethod Function use function to verify input

Output

Name Description
ionFocus on focus
ionBlur on blur

ionic-tags-input's People

Contributors

asimnet avatar fpcuriosity avatar hsuanxyz avatar liuxh0 avatar xxzefgh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ionic-tags-input's Issues

Enhancement Request

Request for following enhancements

  1. provide separate add event

  2. provide separate remove event

  3. ability to specify array of complex models [(ngModel)] = "tags"
    tags = [{name:'Ionic',value:1}, {name:'Angular',value:2}, {name:'TypeScript',value:3}];
    and ability to define what field of the model should be used for input and display on the tag
    "displayField"="name"

regards

Error: Metadata version mismatch for module found version 4

ionic info
cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.19.3
ionic (Ionic CLI) : 3.20.1

global packages:

cordova (Cordova CLI) : 8.0.0 

local packages:

@ionic/app-scripts : 3.2.3
Cordova Platforms  : browser 5.0.4
Ionic Framework    : ionic-angular 3.6.1

System:

Android SDK Tools : 26.1.1
Node              : v10.8.0
npm               : 6.2.0 
OS                : Linux 4.13

Environment Variables:

ANDROID_HOME : /opt/android-sdk-linux

Misc:

backend : pro

The problem occurs when I run this code:
npm run ionic:build -- --prod
image

Could anybody help me with this issue?

Cannot read property 'every' of undefined

Looks like a great component but I am not able to try it because of this error :

ERROR TypeError: Cannot read property 'every' of undefined
at IonTagsInput.isOnce (ionic-tags-input.js:144)
at IonTagsInput.keyAddTag (ionic-tags-input.js:68)
at Object.eval [as handleEvent] (IonTagsInput.html:20)
at handleEvent (core.js:13255)
at callWithDebugContext (core.js:14740)
at Object.debugHandleEvent [as handleEvent] (core.js:14327)
at dispatchEvent (core.js:9704)
at core.js:10318
at platform-browser.js:2614
at platform-browser.js:3673

I installed everything correctly and added it to my app modules.
This is in my HTML:
<ion-tags-input [(ngModel)]="tags" [canEnterAdd]="true">

Did I forget to do something?

Error when using component

Hi
When I add the component to the page I get the following error
No value accessor for form control with unspecified name attribute

I have added the component as follows:
<ion-tags-input
[(ngModel)]="tags"
[color]="'warn'"
[verifyMethod]="tagStrVerify">

If I add ngDefaultControl then the error goes away but the component does not show/load?
<ion-tags-input ngDefaultControl
[(ngModel)]="tags"
[color]="'warn'"
[verifyMethod]="tagStrVerify">

Please advise.
Thanks

Set the focus

How do you focus on the search for this component when you enter this page?

overlap keyboard

content not scrolling when try to enter tags. overlap keyboard ionic 2

random color

Hello,

thank you for designing such a great component..

can we have random color for each entry ?

thank you

Support to Angular Ahead of time compilation

I'm using Angular with Ionic and when building my app with ahead of time compilation, an error is throwing 'cause property '_blur' is private and to support this kind of compilation, the properties of a component should be public at all.

This is a great component and i think that will be a awesome improvement support Ahead of Time in Angular + Ionic.

The error message:
ERROR in node_modules\ionic-tags-input\ionic-tags-input.d.ts.IonTagsInput.html(17,10): : Property '_blur' is private and only accessible within class 'IonTagsInput'. node_modules\ionic-tags-input\ionic-tags-input.d.ts.IonTagsInput.html(18,10): : Expected 0 arguments, but got 1.

iOS - new tag field is seen as one input for the Keyboard Suggestions

When using the ion-tags on iOS the inputs are not seen as single fields, only as one big field.

Example:

  • Typing "Eat" in the first Tag -> Enter
  • Second Input Tag is coming up, when I star typing it comes "Eat Icecream"

When I focus on the second tag (that one that comes up after hitting Enter) it is ok.

I got a workaround idea for that, but anyway, do you have a better solution for that?

Thank you a lot.

'ion-tags-input' is not a known element:

Hello,

Even though I have already imported the module into my project, the following error keeps showing up:

**'ion-tags-input' is not a known element:

  1. If 'ion-tags-input' is an Angular component, then verify that it is part of this module.
  2. If 'ion-tags-input' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("**

The input tags are located in a component which is inserted in a lazy-loaded page.
Any ideas?

Thank you.

lazy loading with ionic 3.5.3

Hello,

this error appeared when I tried to convert my project to lazy loading..
a page containing this component..
screen shot 2017-07-19 at 8 11 29 am

Styles not applied

I've added the package with npm install ionic-tags-input --save and imported the module. I've also set up the event handler and included the component in the html file of my Component, but it seems the styles of the input are not shown.

image

My environment

@ionic/cli-utils  : 1.12.0
   ionic (Ionic CLI) : 3.12.0

local packages:

   @ionic/app-scripts : 1.3.4
   Ionic Framework    : ionic-angular 3.1.1

System:

   Node : v6.11.3
   npm  : 3.10.10
   OS   : Windows 10

Misc:

once doesn't work!..

from #6 move to this

even [once] doesn't work!..

this is my package file:

{
    "name": "ionic-hello-world",
    "version": "0.0.0",
    "author": "Ionic Framework",
    "homepage": "http://ionicframework.com/",
    "private": true,
    "scripts": {
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve"
    },
    "dependencies": {
        "@angular/common": "4.1.3",
        "@angular/compiler": "4.1.3",
        "@angular/compiler-cli": "4.1.3",
        "@angular/core": "4.1.3",
        "@angular/forms": "4.1.3",
        "@angular/http": "4.1.3",
        "@angular/platform-browser": "4.1.3",
        "@angular/platform-browser-dynamic": "4.1.3",
        "@ionic-native/app-availability": "^3.12.1",
        "@ionic-native/camera": "^3.10.3",
        "@ionic-native/core": "3.12.1",
        "@ionic-native/crop": "^3.13.1",
        "@ionic-native/deeplinks": "^3.10.3",
        "@ionic-native/device": "^3.12.1",
        "@ionic-native/email-composer": "^3.12.1",
        "@ionic-native/file": "^3.14.0",
        "@ionic-native/file-transfer": "^4.0.0",
        "@ionic-native/globalization": "^3.10.3",
        "@ionic-native/google-analytics": "^3.10.3",
        "@ionic-native/in-app-browser": "^3.12.1",
        "@ionic-native/keyboard": "^3.12.1",
        "@ionic-native/native-page-transitions": "^3.13.1",
        "@ionic-native/network": "^3.10.3",
        "@ionic-native/onesignal": "^3.10.3",
        "@ionic-native/social-sharing": "^3.10.3",
        "@ionic-native/splash-screen": "3.12.1",
        "@ionic-native/status-bar": "^3.12.1",
        "@ionic-native/transfer": "^3.12.1",
        "@ionic-native/twitter-connect": "^3.10.3",
        "@ionic/storage": "^2.0.1",
        "@ngx-translate/core": "^6.0.1",
        "@ngx-translate/http-loader": "0.0.3",
        "ajv": "^5.2.2",
        "com-sarriaroman-photoviewer": "^1.1.10",
        "cordova-android": "^6.2.3",
        "cordova-android-play-services-gradle-release": "0.0.2",
        "cordova-browser": "^4.1.0",
        "cordova-ios": "^4.4.0",
        "cordova-plugin-appavailability": "^0.4.2",
        "cordova-plugin-camera": "~2.4.1",
        "cordova-plugin-console": "^1.0.5",
        "cordova-plugin-crop": "^0.4.0",
        "cordova-plugin-device": "^1.1.4",
        "cordova-plugin-email": "^1.2.6",
        "cordova-plugin-file": "~4.3.3",
        "cordova-plugin-file-transfer": "~1.6.3",
        "cordova-plugin-globalization": "~1.0.7",
        "cordova-plugin-google-analytics": "~1.8.2",
        "cordova-plugin-inappbrowser": "^1.7.1",
        "cordova-plugin-network-information": "^1.3.3",
        "cordova-plugin-splashscreen": "^4.0.3",
        "cordova-plugin-statusbar": "^2.2.1",
        "cordova-plugin-whitelist": "^1.3.1",
        "cordova-plugin-x-socialsharing": "^5.1.8",
        "cordova-sqlite-storage": "~2.0.4",
        "dargs": "^5.1.0",
        "es6-promise-plugin": "^4.1.0",
        "firebase": "^4.0.0",
        "help": "^3.0.2",
        "imgcache.js": "^1.1.1",
        "install": "^0.10.1",
        "ionic-angular": "3.5.3",
        "ionic-img-viewer": "^2.4.0",
        "ionic-plugin-deeplinks": "^1.0.15",
        "ionic-plugin-keyboard": "^2.2.1",
        "ionic-tags-input": "0.0.6",
        "ionic2-super-tabs": "^2.6.2",
        "ionicons": "3.0.0",
        "node-libs-browser": "^0.4.0",
        "node-sass": "^4.5.3",
        "npm": "^4.6.1",
        "onesignal-cordova-plugin": "~2.1.1",
        "promise-polyfill": "^6.0.2",
        "rxjs": "5.4.0",
        "sw-toolbox": "3.6.0",
        "twitter-connect-plugin": "^0.6.0",
        "webpack": "^1.9.11",
        "zone.js": "0.8.12"
    },
    "devDependencies": {
        "@ionic/app-scripts": "2.0.2",
        "@ionic/cli-plugin-cordova": "1.4.1",
        "@ionic/cli-plugin-gulp": "1.0.2",
        "@ionic/cli-plugin-ionic-angular": "1.3.2",
        "gulp": "^3.9.1",
        "gulp-shell": "^0.6.3",
        "typescript": "2.3.4"
    },
    "cordovaPlugins": [
        "cordova-plugin-whitelist",
        "cordova-plugin-console",
        "cordova-plugin-statusbar",
        "cordova-plugin-device",
        "cordova-plugin-splashscreen",
        "ionic-plugin-keyboard"
    ],
    "cordovaPlatforms": [
        "ios",
        {
            "platform": "ios",
            "version": "",
            "locator": "ios"
        }
    ],
    "description": "myApp: An Ionic project",
    "cordova": {
        "plugins": {
            "ionic-plugin-deeplinks": {
                "URL_SCHEME": "amaniapp",
                "DEEPLINK_SCHEME": "https",
                "DEEPLINK_HOST": "amaniapp.net",
                "ANDROID_PATH_PREFIX": "/",
                "ANDROID_2_PATH_PREFIX": "/",
                "ANDROID_3_PATH_PREFIX": "/",
                "ANDROID_4_PATH_PREFIX": "/",
                "ANDROID_5_PATH_PREFIX": "/",
                "DEEPLINK_2_SCHEME": " ",
                "DEEPLINK_2_HOST": " ",
                "DEEPLINK_3_SCHEME": " ",
                "DEEPLINK_3_HOST": " ",
                "DEEPLINK_4_SCHEME": " ",
                "DEEPLINK_4_HOST": " ",
                "DEEPLINK_5_SCHEME": " ",
                "DEEPLINK_5_HOST": " "
            },
            "cordova-plugin-camera": {
                "CAMERA_USAGE_DESCRIPTION": " ",
                "PHOTOLIBRARY_USAGE_DESCRIPTION": " "
            },
            "cordova-plugin-console": {},
            "cordova-plugin-device": {},
            "cordova-plugin-globalization": {},
            "cordova-plugin-google-analytics": {},
            "cordova-plugin-inappbrowser": {},
            "cordova-plugin-splashscreen": {},
            "cordova-plugin-statusbar": {},
            "cordova-plugin-whitelist": {},
            "cordova-sqlite-storage": {},
            "ionic-plugin-keyboard": {},
            "onesignal-cordova-plugin": {},
            "twitter-connect-plugin": {
                "FABRIC_KEY": "78d8436ce163ffdbf08b972d87713fe341761dc2"
            },
            "cordova-plugin-x-socialsharing": {},
            "cordova-plugin-network-information": {},
            "cordova-plugin-file": {},
            "cordova-plugin-file-transfer": {},
            "cordova-plugin-email": {},
            "cordova-plugin-appavailability": {},
            "cordova-android-play-services-gradle-release": {},
            "cordova-plugin-crop": {},
            "com-sarriaroman-photoviewer": {}
        },
        "platforms": [
            "android",
            "browser",
            "ios"
        ]
    }
}

StencilJS migration

Hello Hsuan,

What do you think about creating a StencilJS component instead? In order to support any framework and version of Ionic

Regards

maxTags input

Hi.
Thanks for the great component.

I am trying to use the maxTags option, but it isn't limiting the tags.
I have tried this:
<ion-tags-input [(ngModel)]="tags" [color]="'warn'" [placeholder]="'Search'" [maxTags]="1"></ion-tags-input>
and this:
<ion-tags-input [(ngModel)]="tags" [color]="'warn'" [placeholder]="'Search'" [maxTags]="'1'"></ion-tags-input>

My project is an ionic 3 app.
Can you help me please?

alert when tag is not accepted

I like to give feedback to the user if the typed tag is not accepted.

So I tried to do it with the alertCtrl by ionic but then I got an error:

Cannot read property 'create' of undefined
    at IonTagsInput.webpackJsonp.54.ReporterPage.verifyTag [as verifyMethod] (reporter.ts:574)
    at IonTagsInput.verifyTag (ionic-tags-input.js:117)
    at IonTagsInput.keyAddTag (ionic-tags-input.js:81)
    at Object.eval [as handleEvent] (IonTagsInput.html:20)
    at handleEvent (core.js:13547)
    at callWithDebugContext (core.js:15056)
    at Object.debugHandleEvent [as handleEvent] (core.js:14643)
    at dispatchEvent (core.js:9962)
    at core.js:10587
    at platform-browser.js:2628

It doesn't matter if I try to do it with local Alertcontroller inside the verify Method. Any solution?

Focus event

How can I use the ionFocus event?
I have tried this:
<ion-tags-input [(ngModel)]="tags" (ionFocus)="onFocus()"></ion-tags-input>

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.