Skip to content

Commit 9f1b1b0

Browse files
authored
Merge pull request #35 from VadimDez/feature/#31
Feature/#31
2 parents 6b3fd4c + d4fe732 commit 9f1b1b0

30 files changed

+494
-201
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.1.10
4+
* [[#31](https://github.com/VadimDez/ng2-filter-pipe/issues/31)] - How to filter by two variables of the same array.
5+
* [[#4](https://github.com/VadimDez/ng2-filter-pipe/issues/4)] - Add $or operator.
6+
37
## 0.1.9
48
* [[#32](https://github.com/VadimDez/ng2-filter-pipe/issues/32)] - Filter fails when filter value is zero
59

README.md

+57
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,63 @@ export class AppComponent {
8383
}
8484
```
8585

86+
### $or matching
87+
Use `$or` to filter by more then one values.
88+
89+
`$or` expects an `Array`.
90+
91+
In your component:
92+
```ts
93+
// your array
94+
const languages = ['English', 'German', 'Russian', 'Italian', 'Ukrainian'];
95+
// your $or filter
96+
const filter = { $or: ['German', 'English'] };
97+
```
98+
99+
In your template:
100+
```html
101+
<div *ngFor="let language of languages | filterBy: filter">
102+
{{ language }}
103+
</div>
104+
```
105+
106+
Result:
107+
```html
108+
<div>English</div>
109+
<div>German</div>
110+
```
111+
112+
#### $or example with nessted values
113+
In your component:
114+
```ts
115+
// your array
116+
const languages = [
117+
{ language: 'English' },
118+
{ language: 'German' },
119+
{ language: 'Italian' }
120+
];
121+
122+
// your $or filter
123+
const filter = {
124+
language: {
125+
$or: ['Italian', 'English']
126+
}
127+
};
128+
```
129+
130+
In your template:
131+
```html
132+
<div *ngFor="let object of languages | filterBy: filter">
133+
{{ object.language }}
134+
</div>
135+
```
136+
137+
Result:
138+
```html
139+
<div>English</div>
140+
<div>Italian</div>
141+
```
142+
86143
## Test
87144

88145
Run tests
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
23
"project": {
3-
"version": "1.0.0-beta.21",
44
"name": "ng-cli"
55
},
66
"apps": [
@@ -13,47 +13,45 @@
1313
],
1414
"index": "index.html",
1515
"main": "main.ts",
16+
"polyfills": "polyfills.ts",
1617
"test": "test.ts",
17-
"tsconfig": "tsconfig.json",
18+
"tsconfig": "tsconfig.app.json",
19+
"testTsconfig": "tsconfig.spec.json",
1820
"prefix": "app",
19-
"mobile": false,
2021
"styles": [
2122
"styles.scss"
2223
],
2324
"scripts": [],
25+
"environmentSource": "environments/environment.ts",
2426
"environments": {
25-
"source": "environments/environment.ts",
2627
"dev": "environments/environment.ts",
2728
"prod": "environments/environment.prod.ts"
2829
}
2930
}
3031
],
31-
"addons": [],
32-
"packages": [],
3332
"e2e": {
3433
"protractor": {
3534
"config": "./protractor.conf.js"
3635
}
3736
},
37+
"lint": [
38+
{
39+
"project": "src/tsconfig.app.json"
40+
},
41+
{
42+
"project": "src/tsconfig.spec.json"
43+
},
44+
{
45+
"project": "e2e/tsconfig.e2e.json"
46+
}
47+
],
3848
"test": {
3949
"karma": {
4050
"config": "./karma.conf.js"
4151
}
4252
},
4353
"defaults": {
44-
"styleExt": "scss",
45-
"prefixInterfaces": false,
46-
"inline": {
47-
"style": false,
48-
"template": false
49-
},
50-
"spec": {
51-
"class": false,
52-
"component": true,
53-
"directive": true,
54-
"module": false,
55-
"pipe": true,
56-
"service": true
57-
}
54+
"styleExt": "css",
55+
"component": {}
5856
}
5957
}

examples/ng-cli/.gitignore

+11-4
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,31 @@
33
# compiled output
44
/dist
55
/tmp
6+
/out-tsc
67

78
# dependencies
89
/node_modules
9-
/bower_components
1010

1111
# IDEs and editors
1212
/.idea
13-
/.vscode
1413
.project
1514
.classpath
1615
.c9/
1716
*.launch
1817
.settings/
18+
*.sublime-workspace
19+
20+
# IDE - VSCode
21+
.vscode/*
22+
!.vscode/settings.json
23+
!.vscode/tasks.json
24+
!.vscode/launch.json
25+
!.vscode/extensions.json
1926

2027
# misc
2128
/.sass-cache
2229
/connect.lock
23-
/coverage/*
30+
/coverage
2431
/libpeerconnection.log
2532
npm-debug.log
2633
testem.log
@@ -30,6 +37,6 @@ testem.log
3037
/e2e/*.js
3138
/e2e/*.map
3239

33-
#System Files
40+
# System Files
3441
.DS_Store
3542
Thumbs.db

examples/ng-cli/README.md

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# NgCli
22

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

55
## Development server
6+
67
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.
78

89
## Code scaffolding
910

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

1213
## Build
1314

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

25-
## Deploying to Github Pages
26-
27-
Run `ng github-pages:deploy` to deploy to Github Pages.
28-
2926
## Further help
3027

31-
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).
28+
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).

examples/ng-cli/e2e/app.e2e-spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NgCliPage } from './app.po';
22

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

66
beforeEach(() => {

examples/ng-cli/e2e/tsconfig.e2e.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../out-tsc/e2e",
5+
"module": "commonjs",
6+
"target": "es5",
7+
"types":[
8+
"jasmine",
9+
"node"
10+
]
11+
}
12+
}

examples/ng-cli/karma.conf.js

+15-20
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,41 @@
44
module.exports = function (config) {
55
config.set({
66
basePath: '',
7-
frameworks: ['jasmine', 'angular-cli'],
7+
frameworks: ['jasmine', '@angular/cli'],
88
plugins: [
99
require('karma-jasmine'),
1010
require('karma-chrome-launcher'),
11-
require('karma-remap-istanbul'),
12-
require('angular-cli/plugins/karma')
11+
require('karma-jasmine-html-reporter'),
12+
require('karma-coverage-istanbul-reporter'),
13+
require('@angular/cli/plugins/karma')
1314
],
15+
client:{
16+
clearContext: false // leave Jasmine Spec Runner output visible in browser
17+
},
1418
files: [
1519
{ pattern: './src/test.ts', watched: false }
1620
],
1721
preprocessors: {
18-
'./src/test.ts': ['angular-cli']
22+
'./src/test.ts': ['@angular/cli']
1923
},
2024
mime: {
2125
'text/x-typescript': ['ts','tsx']
2226
},
23-
remapIstanbulReporter: {
24-
reports: {
25-
html: 'coverage',
26-
lcovonly: './coverage/coverage.lcov'
27-
}
27+
coverageIstanbulReporter: {
28+
reports: [ 'html', 'lcovonly' ],
29+
fixWebpackSourcePaths: true
2830
},
2931
angularCli: {
30-
config: './angular-cli.json',
3132
environment: 'dev'
3233
},
3334
reporters: config.angularCli && config.angularCli.codeCoverage
34-
? ['progress', 'karma-remap-istanbul']
35-
: ['progress'],
35+
? ['progress', 'coverage-istanbul']
36+
: ['progress', 'kjhtml'],
3637
port: 9876,
3738
colors: true,
3839
logLevel: config.LOG_INFO,
3940
autoWatch: true,
40-
browsers: [ process.env.TRAVIS ? 'Chrome_travis_ci' : 'Chrome'],
41-
singleRun: false,
42-
customLaunchers: {
43-
Chrome_travis_ci: {
44-
base: 'Chrome',
45-
flags: ['--no-sandbox']
46-
}
47-
}
41+
browsers: ['Chrome'],
42+
singleRun: false
4843
});
4944
};

examples/ng-cli/package.json

+32-35
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,48 @@
22
"name": "ng2-filter-pipe-example",
33
"version": "0.0.4",
44
"license": "MIT",
5-
"angular-cli": {},
65
"scripts": {
6+
"ng": "ng",
77
"start": "ng serve",
8-
"lint": "tslint \"src/**/*.ts\"",
8+
"build": "ng build",
99
"test": "ng test --watch=false",
10-
"pree2e": "webdriver-manager update",
11-
"e2e": "protractor",
10+
"lint": "ng lint",
11+
"e2e": "ng e2e",
1212
"gh-pages": "ngh --message=\"update\" --dir ./dist"
1313
},
1414
"private": true,
1515
"dependencies": {
16-
"@angular/common": "2.3.1",
17-
"@angular/compiler": "2.3.1",
18-
"@angular/core": "2.3.1",
19-
"@angular/forms": "2.3.1",
20-
"@angular/http": "2.3.1",
21-
"@angular/platform-browser": "2.3.1",
22-
"@angular/platform-browser-dynamic": "2.3.1",
23-
"@angular/router": "3.2.1",
16+
"@angular/common": "^4.0.0",
17+
"@angular/compiler": "^4.0.0",
18+
"@angular/core": "^4.0.0",
19+
"@angular/forms": "^4.0.0",
20+
"@angular/http": "^4.0.0",
21+
"@angular/platform-browser": "^4.0.0",
22+
"@angular/platform-browser-dynamic": "^4.0.0",
23+
"@angular/router": "^4.0.0",
24+
"angular-cli-ghpages": "^0.5.1",
2425
"core-js": "^2.4.1",
25-
"material-design-lite": "^1.2.1",
26-
"ng2-filter-pipe": "0.1.0",
27-
"rxjs": "5.0.0-beta.12",
28-
"ts-helpers": "^1.1.1",
29-
"zone.js": "^0.6.23"
26+
"material-design-lite": "^1.3.0",
27+
"rxjs": "^5.1.0",
28+
"zone.js": "^0.8.4"
3029
},
3130
"devDependencies": {
32-
"@angular/compiler-cli": "2.3.1",
31+
"@angular/cli": "1.0.0",
32+
"@angular/compiler-cli": "^4.0.0",
3333
"@types/jasmine": "2.5.38",
34-
"@types/node": "^6.0.42",
35-
"angular-cli": "1.0.0-beta.21",
36-
"angular-cli-ghpages": "^0.4.1",
37-
"codelyzer": "~1.0.0-beta.3",
38-
"jasmine-core": "2.5.2",
39-
"jasmine-spec-reporter": "2.5.0",
40-
"karma": "1.2.0",
41-
"karma-chrome-launcher": "^2.0.0",
42-
"karma-cli": "^1.0.1",
43-
"karma-jasmine": "^1.0.2",
44-
"karma-remap-istanbul": "^0.2.1",
45-
"protractor": "4.0.9",
46-
"ts-node": "1.2.1",
47-
"tslint": "3.13.0",
48-
"typescript": "~2.0.3",
49-
"typings": "^2.0.0",
50-
"webdriver-manager": "10.2.5"
34+
"@types/node": "~6.0.60",
35+
"codelyzer": "~2.0.0",
36+
"jasmine-core": "~2.5.2",
37+
"jasmine-spec-reporter": "~3.2.0",
38+
"karma": "~1.4.1",
39+
"karma-chrome-launcher": "~2.0.0",
40+
"karma-cli": "~1.0.1",
41+
"karma-jasmine": "~1.1.0",
42+
"karma-jasmine-html-reporter": "^0.2.2",
43+
"karma-coverage-istanbul-reporter": "^0.2.0",
44+
"protractor": "~5.1.0",
45+
"ts-node": "~2.0.0",
46+
"tslint": "~4.5.0",
47+
"typescript": "~2.2.0"
5148
}
5249
}

0 commit comments

Comments
 (0)