@yaireo/tagify
Version:
lightweight, efficient Tags input component in Vanilla JS / React / Angular [super customizable, tiny size & top performance]
45 lines (37 loc) • 989 B
text/typescript
import {ElementRef, Injectable} from '@angular/core';
import * as Tagify from '@yaireo/tagify';
import { SettingsModel } from './angular-tagify.component';
({
providedIn: 'root'
})
export class TagifyService {
private tagify: Tagify;
constructor() {}
/** @description Singleton used by TagifyComponent to a ref to tagify
* @returns tagify instance
*/
getTagifyRef(tagifyInputRef: ElementRef, settings: SettingsModel) {
if (arguments.length === 0) return;
if (this.tagify) return this.tagify;
this.tagify = new Tagify( tagifyInputRef, settings);
return this.tagify;
}
/**
* @description removes all tags
*/
public removeAll() {
this.tagify.removeAllTags();
}
/**
* @description add multiple tags
*/
public addTags(tags) {
this.tagify.addTags(tags);
}
/**
* @description destroy dom and everything
*/
public destroy() {
this.tagify.destroy();
}
}