import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { FiltersModal } from 'src/app/CORE/Modals/DataTables/Filters/filters.modal';
import { Select2OptionData } from 'ng-select2';
import { Options } from 'select2';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
@Component({
selector: 'test',
templateUrl: './test.component.html'
})
export class FiltersComponent implements OnInit {
public exampleData: Array<Select2OptionData>;
public options: Options;
public value: string[];
constructor() { }
ngOnInit() {
this.exampleData = [
{
id: 'multiple1',
text: 'Multiple 1'
},
{
id: 'multiple2',
text: 'Multiple 2'
},
{
id: 'multiple3',
text: 'Multiple 3'
},
{
id: 'multiple4',
text: 'Multiple 4'
}
];
this.value = ['multiple2', 'multiple4'];
this.options = {
width: '300',
multiple: true,
tags: true
};
}
onSearchSubmit(btnType: string) {
this.searchSubmitEvent.emit({ button_type: btnType });
}
}
<ng-select2 [data]="exampleData"
[options]="options"
[width]="500"
[(ngModel)]="value">
</ng-select2>
<br/>
<br/> Selected values: {{ value }}
vendor.js:11632 Uncaught Error: Template parse errors:
Can't bind to 'data' since it isn't a known property of 'ng-select2'.
1. If 'data' is an Angular directive, then add 'CommonModule' to the '@NgModule.imports' of this component.
2. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
<h2>6. Multiple values demo (tags)</h2>
<ng-select2 [ERROR ->][data]="exampleData"
[options]="options"
[width]="500"
"): ng:///Module/FiltersComponent.html@3:14
Can't bind to 'options' since it isn't a known property of 'ng-select2'.
1. If 'options' is an Angular directive, then add 'CommonModule' to the '@NgModule.imports' of this component.
2. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
<ng-select2 [data]="exampleData"
[ERROR ->][options]="options"
[width]="500"
[(ngModel)]="value">
"): ng:///Module/FiltersComponent.html@4:14
Can't bind to 'width' since it isn't a known property of 'ng-select2'.
1. If 'width' is an Angular directive, then add 'CommonModule' to the '@NgModule.imports' of this component.
2. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
<ng-select2 [data]="exampleData"
[options]="options"
[ERROR ->][width]="500"
[(ngModel)]="value">
</ng-select2>
"): ng:///Module/FiltersComponent.html@5:14
Can't bind to 'ngModel' since it isn't a known property of 'ng-select2'.
1. If 'ngModel' is an Angular directive, then add 'CommonModule' to the '@NgModule.imports' of this component.
2. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
[options]="options"
[width]="500"
[ERROR ->][(ngModel)]="value">
</ng-select2>
<br/>
"): ng:///Module/FiltersComponent.html@6:14
'ng-select2' is not a known element:
1. If 'ng-select2' is an Angular component, then verify that it is part of this module.
2. If 'ng-select2' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<h2>6. Multiple values demo (tags)</h2>
[ERROR ->]<ng-select2 [data]="exampleData"
[options]="options"
[width]="500"
"): ng:///Module/FiltersComponent.html@3:2
No provider for NgControl ("
<h2>6. Multiple values demo (tags)</h2>
[ERROR ->]<ng-select2 [data]="exampleData"
[options]="options"
[width]="500"
"): ng:///Module/FiltersComponent.html@3:2
at syntaxError (vendor.js:11632)
at TemplateParser.push../node_modules/@angular/compiler/fesm5/compiler.js.TemplateParser.parse (vendor.js:21180)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._parseTemplate (vendor.js:36295)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileTemplate (vendor.js:36282)
at vendor.js:36225
at Set.forEach (<anonymous>)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileComponents (vendor.js:36225)
at vendor.js:36135
at Object.then (vendor.js:11623)
at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents (vendor.js:36134)
{
"name": "test",
"version": "1.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~8.0.1",
"@angular/common": "~8.0.1",
"@angular/compiler": "~8.0.1",
"@angular/core": "~8.0.1",
"@angular/forms": "~8.0.1",
"@angular/platform-browser": "~8.0.1",
"@angular/platform-browser-dynamic": "~8.0.1",
"@angular/router": "~8.0.1",
"angular-datatables": "^8.0.0",
"bootstrap": "^4.3.1",
"classlist.js": "^1.1.20150312",
"datatables.net": "^1.10.19",
"datatables.net-dt": "^1.10.19",
"jquery": "^3.4.1",
"ng-select2": "^1.1.2",
"ngx-bootstrap": "^5.1.0",
"popper.js": "^1.15.0",
"rxjs": "~6.4.0",
"select2": "^4.0.8",
"tslib": "^1.9.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.800.0",
"@angular/cli": "~8.0.4",
"@angular/compiler-cli": "~8.0.1",
"@angular/language-service": "~8.0.1",
"@fortawesome/fontawesome-free": "^5.9.0",
"@types/datatables.net": "^1.10.17",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"@types/jquery": "^3.3.30",
"@types/node": "~8.9.4",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.15.0",
"typescript": "~3.4.3"
}
}
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"node_modules/select2/dist/css/select2.min.css"
],
"scripts": [
"node_modules/jquery/dist/jquery.js",
"node_modules/select2/dist/js/select2.min.js"
]
},