Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
formation-angular
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Emile TAVERNE
formation-angular
Commits
7ec76fdf
Commit
7ec76fdf
authored
7 years ago
by
Emile TAVERNE
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ajout pipes orderBy et capitalize
parent
88bfb38a
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
5 deletions
+32
-5
app.component.html
trombinoscope/src/app/app.component.html
+1
-1
app.component.ts
trombinoscope/src/app/app.component.ts
+0
-2
app.module.ts
trombinoscope/src/app/app.module.ts
+4
-1
card.component.html
trombinoscope/src/app/components/card/card.component.html
+1
-1
capitalize.pipe.ts
trombinoscope/src/app/pipes/capitalize.pipe.ts
+8
-0
index.ts
trombinoscope/src/app/pipes/index.ts
+2
-0
order-by-full-name.pipe.ts
trombinoscope/src/app/pipes/order-by-full-name.pipe.ts
+16
-0
No files found.
trombinoscope/src/app/app.component.html
View file @
7ec76fdf
...
@@ -6,6 +6,6 @@
...
@@ -6,6 +6,6 @@
</header>
</header>
<div
class=
"w80 center ptm"
>
<div
class=
"w80 center ptm"
>
<div
class=
"grid-4 has-gutter"
>
<div
class=
"grid-4 has-gutter"
>
<app-card
*
ngFor=
"let person of persons"
[
person
]="
person
"
></app-card>
<app-card
*
ngFor=
"let person of persons
| orderByFullName
"
[
person
]="
person
"
></app-card>
</div>
</div>
</div>
</div>
This diff is collapsed.
Click to expand it.
trombinoscope/src/app/app.component.ts
View file @
7ec76fdf
...
@@ -8,8 +8,6 @@ import {DataService} from "./services/data.service";
...
@@ -8,8 +8,6 @@ import {DataService} from "./services/data.service";
styleUrls
:
[
'./app.component.css'
]
styleUrls
:
[
'./app.component.css'
]
})
})
export
class
AppComponent
implements
OnInit
{
export
class
AppComponent
implements
OnInit
{
private
readonly
nbPerson
:
number
=
10
;
private
persons
:
PersonModel
[]
=
[];
private
persons
:
PersonModel
[]
=
[];
constructor
(
private
dataService
:
DataService
)
{
constructor
(
private
dataService
:
DataService
)
{
...
...
This diff is collapsed.
Click to expand it.
trombinoscope/src/app/app.module.ts
View file @
7ec76fdf
...
@@ -5,11 +5,14 @@ import {HttpClientModule} from '@angular/common/http';
...
@@ -5,11 +5,14 @@ import {HttpClientModule} from '@angular/common/http';
import
{
AppComponent
}
from
'./app.component'
;
import
{
AppComponent
}
from
'./app.component'
;
import
*
as
Components
from
'./components'
;
import
*
as
Components
from
'./components'
;
import
*
as
Services
from
'./services'
;
import
*
as
Services
from
'./services'
;
import
*
as
Pipes
from
'./pipes'
;
@
NgModule
({
@
NgModule
({
declarations
:
[
declarations
:
[
AppComponent
,
AppComponent
,
Components
.
CardComponent
Components
.
CardComponent
,
Pipes
.
CapitalizePipe
,
Pipes
.
OrderByFullNamePipe
],
],
imports
:
[
imports
:
[
BrowserModule
,
BrowserModule
,
...
...
This diff is collapsed.
Click to expand it.
trombinoscope/src/app/components/card/card.component.html
View file @
7ec76fdf
<div
class=
"card pam mtm tbm"
>
<div
class=
"card pam mtm tbm"
>
<h2
class=
"txtcenter"
>
{{person.firstname }} {{person.lastname | uppercase}}
</h2>
<h2
class=
"txtcenter"
>
{{person.firstname
| capitalize
}} {{person.lastname | uppercase}}
</h2>
<img
*
ngIf=
"person.image; else elseBlock"
class=
"center w100"
[
src
]="
person
.
image
"
>
<img
*
ngIf=
"person.image; else elseBlock"
class=
"center w100"
[
src
]="
person
.
image
"
>
<ng-template
#
elseBlock
>
<ng-template
#
elseBlock
>
<img
class=
"center w100"
[
src
]="
defaultImages
.
get
(
person
.
gender
)"
>
<img
class=
"center w100"
[
src
]="
defaultImages
.
get
(
person
.
gender
)"
>
...
...
This diff is collapsed.
Click to expand it.
trombinoscope/src/app/pipes/capitalize.pipe.ts
0 → 100644
View file @
7ec76fdf
import
{
Pipe
,
PipeTransform
}
from
'@angular/core'
;
@
Pipe
({
name
:
'capitalize'
})
export
class
CapitalizePipe
implements
PipeTransform
{
transform
(
value
:
string
):
string
{
return
value
.
charAt
(
0
).
toUpperCase
()
+
value
.
slice
(
1
);
}
}
This diff is collapsed.
Click to expand it.
trombinoscope/src/app/pipes/index.ts
0 → 100644
View file @
7ec76fdf
export
*
from
'./capitalize.pipe'
;
export
*
from
'./order-by-full-name.pipe'
;
This diff is collapsed.
Click to expand it.
trombinoscope/src/app/pipes/order-by-full-name.pipe.ts
0 → 100644
View file @
7ec76fdf
import
{
Pipe
,
PipeTransform
}
from
'@angular/core'
;
import
{
PersonModel
}
from
"../../models"
;
@
Pipe
({
name
:
'orderByFullName'
})
export
class
OrderByFullNamePipe
implements
PipeTransform
{
transform
(
value
:
PersonModel
[]):
PersonModel
[]
{
return
value
.
sort
((
a
:
PersonModel
,
b
:
PersonModel
):
number
=>
{
const
fullNameA
=
`
${
a
.
firstname
}
${
a
.
lastname
}
`
;
const
fullNameB
=
`
${
b
.
firstname
}
${
b
.
lastname
}
`
;
if
(
fullNameA
<
fullNameB
)
return
-
1
;
if
(
fullNameA
>
fullNameB
)
return
1
;
return
0
;
});
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment