Skip to content

Commit

Permalink
Merge pull request #35 from VadimDez/feature/#31
Browse files Browse the repository at this point in the history
Feature/#31
  • Loading branch information
VadimDez authored Jun 1, 2017
2 parents 6b3fd4c + d4fe732 commit 9f1b1b0
Show file tree
Hide file tree
Showing 30 changed files with 494 additions and 201 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.1.10
* [[#31](https://github.com/VadimDez/ng2-filter-pipe/issues/31)] - How to filter by two variables of the same array.
* [[#4](https://github.com/VadimDez/ng2-filter-pipe/issues/4)] - Add $or operator.

## 0.1.9
* [[#32](https://github.com/VadimDez/ng2-filter-pipe/issues/32)] - Filter fails when filter value is zero

Expand Down
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,63 @@ export class AppComponent {
}
```

### $or matching
Use `$or` to filter by more then one values.

`$or` expects an `Array`.

In your component:
```ts
// your array
const languages = ['English', 'German', 'Russian', 'Italian', 'Ukrainian'];
// your $or filter
const filter = { $or: ['German', 'English'] };
```

In your template:
```html
<div *ngFor="let language of languages | filterBy: filter">
{{ language }}
</div>
```

Result:
```html
<div>English</div>
<div>German</div>
```

#### $or example with nessted values
In your component:
```ts
// your array
const languages = [
{ language: 'English' },
{ language: 'German' },
{ language: 'Italian' }
];

// your $or filter
const filter = {
language: {
$or: ['Italian', 'English']
}
};
```

In your template:
```html
<div *ngFor="let object of languages | filterBy: filter">
{{ object.language }}
</div>
```

Result:
```html
<div>English</div>
<div>Italian</div>
```

## Test

Run tests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"version": "1.0.0-beta.21",
"name": "ng-cli"
},
"apps": [
Expand All @@ -13,47 +13,45 @@
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"mobile": false,
"styles": [
"styles.scss"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"source": "environments/environment.ts",
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"addons": [],
"packages": [],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json"
},
{
"project": "src/tsconfig.spec.json"
},
{
"project": "e2e/tsconfig.e2e.json"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "scss",
"prefixInterfaces": false,
"inline": {
"style": false,
"template": false
},
"spec": {
"class": false,
"component": true,
"directive": true,
"module": false,
"pipe": true,
"service": true
}
"styleExt": "css",
"component": {}
}
}
15 changes: 11 additions & 4 deletions examples/ng-cli/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,31 @@
# compiled output
/dist
/tmp
/out-tsc

# dependencies
/node_modules
/bower_components

# IDEs and editors
/.idea
/.vscode
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage/*
/coverage
/libpeerconnection.log
npm-debug.log
testem.log
Expand All @@ -30,6 +37,6 @@ testem.log
/e2e/*.js
/e2e/*.map

#System Files
# System Files
.DS_Store
Thumbs.db
11 changes: 4 additions & 7 deletions examples/ng-cli/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# NgCli

This project was generated with [angular-cli](https://github.com/angular/angular-cli) version 1.0.0-beta.21.
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.0.0.

## Development server

Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.

## Code scaffolding

Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive/pipe/service/class`.
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive/pipe/service/class/module`.

## Build

Expand All @@ -22,10 +23,6 @@ Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
Before running the tests make sure you are serving the app via `ng serve`.

## Deploying to Github Pages

Run `ng github-pages:deploy` to deploy to Github Pages.

## Further help

To get more help on the `angular-cli` use `ng --help` or go check out the [Angular-CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
2 changes: 1 addition & 1 deletion examples/ng-cli/e2e/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NgCliPage } from './app.po';

describe('ng-cli App', function() {
describe('ng-cli App', () => {
let page: NgCliPage;

beforeEach(() => {
Expand Down
12 changes: 12 additions & 0 deletions examples/ng-cli/e2e/tsconfig.e2e.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/e2e",
"module": "commonjs",
"target": "es5",
"types":[
"jasmine",
"node"
]
}
}
35 changes: 15 additions & 20 deletions examples/ng-cli/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,41 @@
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', 'angular-cli'],
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-remap-istanbul'),
require('angular-cli/plugins/karma')
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma')
],
client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
files: [
{ pattern: './src/test.ts', watched: false }
],
preprocessors: {
'./src/test.ts': ['angular-cli']
'./src/test.ts': ['@angular/cli']
},
mime: {
'text/x-typescript': ['ts','tsx']
},
remapIstanbulReporter: {
reports: {
html: 'coverage',
lcovonly: './coverage/coverage.lcov'
}
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},
angularCli: {
config: './angular-cli.json',
environment: 'dev'
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'karma-remap-istanbul']
: ['progress'],
? ['progress', 'coverage-istanbul']
: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: [ process.env.TRAVIS ? 'Chrome_travis_ci' : 'Chrome'],
singleRun: false,
customLaunchers: {
Chrome_travis_ci: {
base: 'Chrome',
flags: ['--no-sandbox']
}
}
browsers: ['Chrome'],
singleRun: false
});
};
67 changes: 32 additions & 35 deletions examples/ng-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,48 @@
"name": "ng2-filter-pipe-example",
"version": "0.0.4",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\"",
"build": "ng build",
"test": "ng test --watch=false",
"pree2e": "webdriver-manager update",
"e2e": "protractor",
"lint": "ng lint",
"e2e": "ng e2e",
"gh-pages": "ngh --message=\"update\" --dir ./dist"
},
"private": true,
"dependencies": {
"@angular/common": "2.3.1",
"@angular/compiler": "2.3.1",
"@angular/core": "2.3.1",
"@angular/forms": "2.3.1",
"@angular/http": "2.3.1",
"@angular/platform-browser": "2.3.1",
"@angular/platform-browser-dynamic": "2.3.1",
"@angular/router": "3.2.1",
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"angular-cli-ghpages": "^0.5.1",
"core-js": "^2.4.1",
"material-design-lite": "^1.2.1",
"ng2-filter-pipe": "0.1.0",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.23"
"material-design-lite": "^1.3.0",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/compiler-cli": "2.3.1",
"@angular/cli": "1.0.0",
"@angular/compiler-cli": "^4.0.0",
"@types/jasmine": "2.5.38",
"@types/node": "^6.0.42",
"angular-cli": "1.0.0-beta.21",
"angular-cli-ghpages": "^0.4.1",
"codelyzer": "~1.0.0-beta.3",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.9",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "~2.0.3",
"typings": "^2.0.0",
"webdriver-manager": "10.2.5"
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-coverage-istanbul-reporter": "^0.2.0",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0"
}
}
Loading

0 comments on commit 9f1b1b0

Please sign in to comment.