{"id":26245226,"url":"https://github.com/solidexpert-ltd/ngx-query-builder","last_synced_at":"2026-03-03T02:31:43.500Z","repository":{"id":281906517,"uuid":"946832954","full_name":"solidexpert-ltd/ngx-query-builder","owner":"solidexpert-ltd","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-11T18:54:07.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-11T19:38:21.895Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/solidexpert-ltd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-11T18:40:58.000Z","updated_at":"2025-03-11T18:54:11.000Z","dependencies_parsed_at":"2025-03-11T19:48:25.482Z","dependency_job_id":null,"html_url":"https://github.com/solidexpert-ltd/ngx-query-builder","commit_stats":null,"previous_names":["solidexpert-ltd/ngx-query-builder"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solidexpert-ltd%2Fngx-query-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solidexpert-ltd%2Fngx-query-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solidexpert-ltd%2Fngx-query-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solidexpert-ltd%2Fngx-query-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/solidexpert-ltd","download_url":"https://codeload.github.com/solidexpert-ltd/ngx-query-builder/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243405632,"owners_count":20285788,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-13T12:32:30.639Z","updated_at":"2026-03-03T02:31:38.477Z","avatar_url":"https://github.com/solidexpert-ltd.png","language":"TypeScript","funding_links":[],"categories":["Third Party Components"],"sub_categories":["Forms"],"readme":"# Angular-QueryBuilder\nA modernized Angular 4+ query builder based on jQuery QueryBuilder. Support for heavy customization with Angular components and provides a flexible way to handle custom data types.\n\n# Getting Started\n\n## Install\n\n- Angular 15 use 15.0.x\n- Angular 19 use 19.0.x\n\n`npm install @solidexpert/ngx-query-builder`\n\n# Examples\n\n## Basic Usage\n\n##### `app.module.ts`\n```javascript\nimport { QueryBuilderModule } from \"@solidexpert/ngx-query-builder\";\nimport { AppComponent } from \"./app.component\"\n\n@NgModule(imports: [\n  ...,\n  QueryBuilderModule,\n])\nexport class AppModule { }\n```\n\n##### `app.component.html`\n```html\n...\n\u003cquery-builder [(ngModel)]='query' [config]='config'\u003e\u003c/query-builder\u003e\n...\n```\n##### `app.component.ts`\n```javascript\nimport { QueryBuilderConfig } from '@solidexpert/ngx-query-builder';\n\nexport class AppComponent {\n  query = {\n    condition: 'and',\n    rules: [\n      {field: 'age', operator: '\u003c=', value: 'Bob'},\n      {field: 'gender', operator: '\u003e=', value: 'm'}\n    ]\n  };\n  \n  config: QueryBuilderConfig = {\n    fields: {\n      age: {name: 'Age', type: 'number'},\n      gender: {\n        name: 'Gender',\n        type: 'category',\n        options: [\n          {name: 'Male', value: 'm'},\n          {name: 'Female', value: 'f'}\n        ]\n      }\n    }\n  }\n}\n```\n\n## Custom Input Components\n\n##### `app.component.html`\n```html\n\u003cquery-builder [(ngModel)]='query' [config]='config'\u003e\n  \u003cng-container *queryInput=\"let rule; type: 'date'\"\u003e\n    \u003ccustom-datepicker [(ngModel)]=\"rule.value\"\u003e\u003c/custom-datepicker\u003e\n  \u003c/ng-container\u003e\n\u003c/query-builder\u003e\n```\n\n##### `app.component.ts`\n```javascript\nquery = {\n  condition: 'and',\n  rules: [\n    {field: 'birthday', operator: '=', value: new Date()}\n  ]\n};\n\nconfig: QueryBuilderConfig = {\n  fields: {\n    birthday: {name: 'Birthday', type: 'date', operators: ['=', '\u003c=', '\u003e']\n      defaultValue: (() =\u003e return new Date())\n    },\n  }\n}\n```\n\n## Custom Styling (with Bootstrap 4)\n\n\n##### `app.component.html`\n```html\n\u003cquery-builder [(ngModel)]='query' [config]='config' [classNames]='classNames'\u003e\u003c/query-builder\u003e\n```\n##### `app.component.ts`\n```javascript\nclassNames: QueryBuilderClassNames = {\n  removeIcon: 'fa fa-minus',\n  addIcon: 'fa fa-plus',\n  arrowIcon: 'fa fa-chevron-right px-2',\n  button: 'btn',\n  buttonGroup: 'btn-group',\n  rightAlign: 'order-12 ml-auto',\n  switchRow: 'd-flex px-2',\n  switchGroup: 'd-flex align-items-center',\n  switchRadio: 'custom-control-input',\n  switchLabel: 'custom-control-label',\n  switchControl: 'custom-control custom-radio custom-control-inline',\n  row: 'row p-2 m-1',\n  rule: 'border',\n  ruleSet: 'border',\n  invalidRuleSet: 'alert alert-danger',\n  emptyWarning: 'text-danger mx-auto',\n  operatorControl: 'form-control',\n  operatorControlSize: 'col-auto pr-0',\n  fieldControl: 'form-control',\n  fieldControlSize: 'col-auto pr-0',\n  entityControl: 'form-control',\n  entityControlSize: 'col-auto pr-0',\n  inputControl: 'form-control',\n  inputControlSize: 'col-auto'\n}\n```\n\n## Customizing with Angular Material\n\nExample of how you can completely customize the query component with another library like Angular Material. For the full example, please look at the [source code](https://github.com/zebzhao/Angular-QueryBuilder/blob/master/demo/src/app/app.component.ts) provided in the demo.\n\n#### `app.component.html`\n\n```html\n\u003cquery-builder [(ngModel)]='query' [config]='config'\u003e\n  \u003cng-container *queryButtonGroup=\"let ruleset; let addRule=addRule; let addRuleSet=addRuleSet; let removeRuleSet=removeRuleSet\"\u003e\n    \u003cbutton type=\"button\" mat-button (click)=\"addRule()\"\u003e+ Rule\u003c/button\u003e\n    \u003cbutton type=\"button\" mat-button (click)=\"addRuleSet()\"\u003e+ Ruleset\u003c/button\u003e\n    \u003cbutton type=\"button\" mat-button (click)=\"removeRuleSet()\"\u003e- Ruleset\u003c/button\u003e\n  \u003c/ng-container\u003e\n  \u003cng-container *queryRemoveButton=\"let rule; let removeRule=removeRule\"\u003e\n    \u003cbutton type=\"button\" mat-icon-button color=\"accent\" (click)=\"removeRule(rule)\"\u003e\n      \u003cmat-icon\u003eremove\u003c/mat-icon\u003e\n    \u003c/button\u003e\n  \u003c/ng-container\u003e\n  \u003cng-container *querySwitchGroup=\"let ruleset\"\u003e\n    \u003cmat-radio-group *ngIf=\"ruleset\" [(ngModel)]=\"ruleset.condition\"\u003e\n      \u003cmat-radio-button value=\"and\"\u003eAnd\u003c/mat-radio-button\u003e\n      \u003cmat-radio-button value=\"or\"\u003eOr\u003c/mat-radio-button\u003e\n    \u003c/mat-radio-group\u003e\n  \u003c/ng-container\u003e\n  \u003cng-container *queryField=\"let rule; let fields=fields; let onChange=onChange\"\u003e\n    \u003cmat-form-field\u003e\n      \u003cmat-select [(ngModel)]=\"rule.field\" (ngModelChange)=\"onChange($event, rule)\"\u003e\n        \u003cmat-option *ngFor=\"let field of fields\" [value]=\"field.value\"\u003e{{field.name}}\u003c/mat-option\u003e\n      \u003c/mat-select\u003e\n    \u003c/mat-form-field\u003e\n  \u003c/ng-container\u003e\n  \u003cng-container *queryOperator=\"let rule; let operators=operators\"\u003e\n    \u003cmat-form-field\u003e\n      \u003cmat-select [(ngModel)]=\"rule.operator\"\u003e\n        \u003cmat-option *ngFor=\"let value of operators\" [value]=\"value\"\u003e{{value}}\u003c/mat-option\u003e\n      \u003c/mat-select\u003e\n    \u003c/mat-form-field\u003e\n  \u003c/ng-container\u003e\n  \u003c!-- Override input component for 'boolean' type --\u003e\n  \u003cng-container *queryInput=\"let rule; type: 'boolean'\"\u003e\n    \u003cmat-checkbox [(ngModel)]=\"rule.value\"\u003e\u003c/mat-checkbox\u003e\n  \u003c/ng-container\u003e\n  \u003c!-- Override input component for 'category' type --\u003e\n  \u003cng-container *queryInput=\"let rule; let field=field; let options=options; type: 'category'\"\u003e\n    \u003cmat-form-field\u003e\n      \u003cmat-select [(ngModel)]=\"rule.value\" [placeholder]=\"field.name\"\u003e\n        \u003cmat-option *ngFor=\"let opt of options\" [value]=\"opt.value\"\u003e\n          {{ opt.name }}\n        \u003c/mat-option\u003e\n      \u003c/mat-select\u003e\n    \u003c/mat-form-field\u003e\n  \u003c/ng-container\u003e\n  ...\n\u003c/query-builder\u003e\n```\n\n## Property Bindings Quick Reference\n\nSee [documentation](https://zebzhao.github.io/Angular-QueryBuilder/) for more details on interfaces and properties.\n\n#### `query-builder`\n|Name|Type|Required|Default|Description|\n|:--- |:--- |:--- |:--- |:--- |\n|`allowRuleset`|`boolean`|Optional|`true`| Displays the `+ Ruleset` button if `true`. |\n|`allowCollapse`|`boolean`|Optional|`false`| Enables collapsible rule sets if `true`. ([See Demo](https://zebzhao.github.io/Angular-QueryBuilder/demo/)) |\n|`classNames`|`object`|Optional|| CSS class names for different child elements in `query-builder` component. |\n|`config`|`QueryBuilderConfig`|Required|| Configuration object for the main component. |\n|`data`|`Ruleset`|Optional|| (Use `ngModel` or `value` instead.) |\n|`emptyMessage`|`string`|Optional|| Message to display for an empty Ruleset if empty rulesets are not allowed. |\n|`ngModel`| `Ruleset` |Optional|| Object that stores the state of the component. Supports 2-way binding. |\n|`operatorMap`|`{ [key: string]: string[] }`|Optional|| Used to map field types to list of operators. |\n|`persistValueOnFieldChange`|`boolean`|Optional|`false`| If `true`, when a field changes to another of the same type, and the type is one of: string, number, time, date, or boolean, persist the previous value. This option is ignored if config.calculateFieldChangeValue is provided. |\n|`config.calculateFieldChangeValue`|`(currentField: Field, nextField: Field, currentValue: any) =\u003e any`|Optional|| Used to calculate the new value when a rule's field changes. |\n|`value`| `Ruleset` |Optional|| Object that stores the state of the component. |\n\n## Structural Directives\n\nUse these directives to replace different parts of query builder with custom components. See [example](#customizing-with-angular-material), or [demo](https://zebzhao.github.io/Angular-QueryBuilder/demo/) to see how it's done.\n\n#### `queryInput`\n\nUsed to replace the input component. Specify the type/queryInputType to match specific field types to input template.\n\n|Context Name|Type|Description|\n|:--- |:--- |:--- |\n|`$implicit`|`Rule`|Current rule object which contains the field, value, and operator|\n|`field`|`Field`|Current field object which contains the field's value and name|\n|`options`|`Option[]`|List of options for the field, returned by `getOptions`|\n|`onChange`|`() =\u003e void`|Callback to handle changes to the input component|\n\n#### `queryOperator`\n\nUsed to replace the query operator selection component.\n\n|Context Name|Type|Description|\n|:--- |:--- |:--- |\n|`$implicit`|`Rule`|Current rule object which contains the field, value, and operator|\n|`operators`|`string[]`|List of operators for the field, returned by `getOperators`|\n|`onChange`|`() =\u003e void`|Callback to handle changes to the operator component|\n|`type`|`string`|Input binding specifying the field type mapped to this input template, specified using syntax in above example|\n\n#### `queryField`\n\nUsed this directive to replace the query field selection component.\n\n|Context Name|Type|Description|\n|:--- |:--- |:--- |\n|`$implicit`|`Rule`|Current rule object which contains the field, value, and operator|\n|`getFields`|`(entityName: string) =\u003e void`|Get the list of fields corresponding to an entity|\n|`fields`|`Field[]`|List of fields for the component, specified by `config`|\n|`onChange`|`(fieldValue: string, rule: Rule) =\u003e void`|Callback to handle changes to the field component|\n\n#### `queryEntity`\n\nUsed to replace entity selection component.\n\n|Context Name|Type|Description|\n|:--- |:--- |:--- |\n|`$implicit`|`Rule`|Current rule object which contains the field, value, and operator|\n|`entities`|`Entity[]`|List of entities for the component, specified by `config`|\n|`onChange`|`(entityValue: string, rule: Rule) =\u003e void`|Callback to handle changes to the entity component|\n\n#### `querySwitchGroup`\n\nUseful for replacing the switch controls, for example the AND/OR conditions. More custom conditions can be specified by using this directive to override the default component.\n\n|Context Name|Type|Description|\n|:--- |:--- |:--- |\n|`$implicit`|`RuleSet`|Current rule set object which contain a list of child rules|\n|`onChange`|`() =\u003e void`|Callback to handle changes to the switch group component|\n\n#### `queryArrowIcon`\n\nDirective to replace the expand arrow used in collapse/accordion mode of the query builder.\n\n|Context Name|Type|Description|\n|:--- |:--- |:--- |\n|`$implicit`|`RuleSet`|Current rule set object which contain a list of child rules|\n\n#### `queryEmptyWarning`\n\nCan be used to customize the default empty warning message, alternatively can specify the `emptyMessage` property binding.\n\n|Context Name|Type|Description|\n|:--- |:--- |:--- |\n|`$implicit`|`RuleSet`|Current rule set object which contain a list of child rules|\n|`message`|`string`|Value passed to `emptyMessage`|\n\n#### `queryButtonGroup`\n\nFor replacing the default button group for Add, Add Ruleset, Remove Ruleset buttons.\n\n|Context Name|Type|Description|\n|:--- |:--- |:--- |\n|`$implicit`|`RuleSet`|Current rule set object which contain a list of child rules|\n|`addRule`|`() =\u003e void`|Function to handle adding a new rule|\n|`addRuleSet`|`() =\u003e void`|Function to handle adding a new rule set|\n|`removeRuleSet`|`() =\u003e void`|Function to handle removing the current rule set|\n\n#### `queryRemoveButton`\n\nDirective to replace the default remove single rule button component.\n\n|Context Name|Type|Description|\n|:--- |:--- |:--- |\n|`$implicit`|`Rule`|Current rule object which contains the field, value, and operator|\n|`removeRule`|`(rule: Rule) =\u003e void`|Function to handle removing a rule|\n\n## Dependencies\n- Angular 8+\n\nThat's it.\n\n# Workflow\nSee the [angular-library-seed](https://github.com/trekhleb/angular-library-seed) project for details on how to build and run tests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolidexpert-ltd%2Fngx-query-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsolidexpert-ltd%2Fngx-query-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolidexpert-ltd%2Fngx-query-builder/lists"}