【问题标题】:How to implement multiple tagging in ionic 3 or angular 4如何在 ionic 3 或 angular 4 中实现多个标记
【发布时间】:2017-10-23 10:00:31
【问题描述】:

我想实现 multiple tagging 我不知道任何具体的包。

我想为这组data 拥有多个tagging

skills = ['javascript','angular 4','css','php',..............];

我想要类似的multiple tagging 就像select2 这里是演示:https://select2.org/tagging

提前致谢!!!!

【问题讨论】:

    标签: angular jquery-select2 ionic3


    【解决方案1】:

    关于ionic3,你可以使用下面提到的npm包

    npm install ng2-tag-input
    

    安装包后,需要像这样在模块文件中添加依赖,

    app.module.ts

    import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
    import { TagInputModule } from 'ng2-tag-input';
    
    imports: [
         BrowserAnimationsModule,
         TagInputModule
      ]
    

    例如,如果您有一个名为 home 的组件,那么您需要在 home.ts 文件中添加这样的代码,

    home.ts

    import { Component } from '@angular/core';
    import { NavController } from 'ionic-angular';
    
    @Component({
      selector: 'page-home',
      templateUrl: 'home.html'
    })
    export class HomePage {
    
        skills = ['javascript','angular 4','css','php'];
    
     constructor(public navCtrl: NavController) {
    
     }
    
    }
    

    最后在你的模板文件中你需要写这样的东西,

    home.html

    <tag-input [(ngModel)]='skills'></tag-input>
    

    【讨论】:

    • 先生,我遵循了每一步,但我得到了这个errorUncaught (in promise): Error: Template parse errors: 'tag-input' is not a known element: 1. If 'tag-input' is an Angular component, then verify that it is part of this module. 2. If 'tag-input' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. (" &lt;ion-content padding&gt; [ERROR -&gt;]&lt;tag-input [(ngModel)]="skills"&gt;&lt;/tag-input&gt; &lt;/ion-content&gt; "): ng:///TagsPageModule/TagsPage.html@16:4 Error: Template parse errors: 'tag-input' is not a known element: 1. I
    • 先卸载包,然后尝试使用 npm install ng2-tag-input --save 这个命令安装包
    • @AddWebSolutionPvtLtd,我有unistalledinstalled 但得到相同的error
    • @EaB:cli 包:(/usr/lib/node_modules)@ionic/cli-utils:1.12.0 离子(Ionic CLI):3.12.0 全局包:cordova(Cordova CLI): 7.0.1 本地包:@ionic/app-scripts:3.0.0 Cordova 平台:android 6.2.3 Ionic 框架:ionic-angular 3.7.1 系统:Android SDK 工具:26.1.1 节点:v6.11.4 npm:3.10。 10 操作系统:Linux 4.4 杂项:后端:遗留
    • @EaB:上面是我的离子信息,上面提到的代码对我有用。请将其与您的离子信息进行比较
    猜你喜欢
    • 1970-01-01
    • 2018-03-17
    • 2015-09-02
    • 1970-01-01
    • 1970-01-01
    • 2018-03-10
    • 2017-09-09
    • 2018-11-08
    • 1970-01-01
    相关资源
    最近更新 更多