FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ionic/ionic/decorators/page.ts at labels-refactor · Java1024/ionic · GitHub
Java1024
ionic
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ionic
/
ionic
/
decorators
/
page.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
111 lines (107 loc) · 3.26 KB
Breadcrumbs
ionic
/
ionic
/
decorators
/
page.ts
Copy path
File metadata and controls
111 lines (107 loc) · 3.26 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import
{
Component
,
ChangeDetectionStrategy
,
ViewEncapsulation
,
Type
}
from
'angular2/core'
import
{
IONIC_DIRECTIVES
}
from
'../config/directives'
;
const
_reflect
:
any
=
Reflect
;
export
interface
PageMetadata
{
selector
?:
string
;
inputs
?:
string
[
]
;
outputs
?:
string
[
]
;
properties
?:
string
[
]
;
events
?:
string
[
]
;
host
?:
{
[
key
:
string
]
:
string
;
}
;
providers
?:
any
[
]
;
directives
?:
Array
<
Type
|
any
[
]
>
;
pipes
?:
Array
<
Type
|
any
[
]
>
;
exportAs
?:
string
;
queries
?:
{
[
key
:
string
]
:
any
;
}
;
template
?:
string
;
templateUrl
?:
string
;
moduleId
?:
string
;
styleUrls
?:
string
[
]
;
styles
?:
string
[
]
;
changeDetection
?:
ChangeDetectionStrategy
;
encapsulation
?:
ViewEncapsulation
;
}
/**
*
@name
Page
*
@description
*
* The Page decorator indicates that the decorated class is an Ionic
* navigation component, meaning it can be navigated to using a NavController.
*
* Pages have all `IONIC_DIRECTIVES`, which include all Ionic components and directives,
* as well as Angular's [CORE_DIRECTIVES](https://angular.io/docs/js/latest/api/core/CORE_DIRECTIVES-const.html)
* and [FORM_DIRECTIVES](https://angular.io/docs/js/latest/api/core/FORM_DIRECTIVES-const.html),
* already provided to them, so you only need to supply custom components and directives to your pages:
*
*
@usage
*
* ```ts
*
@Page
({
* template: `
* <ion-content>
* I am a page!
* </ion-content>
* `
* })
* class MyPage {}
* ```
*
* Here [Content](../../../components/content/Content/) will load because
* it is in `IONIC_DIRECTIVES`, so there is no need to add a `directives` array.
*
*
* Say you built a custom component that uses the already existing Ionic component.
* In this case, you would add `IONIC_DIRECTIVES` to your directives array.
*
* ```ts
* import {IONIC_DIRECTIVES} from 'ionic-angular';
*
@Component
({
* selector: 'my-component'
* template: `<div class="my-style">
* <ion-checkbox></ion-checkbox>
* </div>`,
* directives: [IONIC_DIRECTIVES]
* })
* class MyCustomCheckbox {}
*```
* Alternatively, you could:
*
* ```ts
* import {Checkbox, Icon} from 'ionic-angular'
* ```
*
* along with any other components and add them individually:
*
* ```
*
@Component
({
* ...
* directives: [Checkbox, Icon]
* })
* ```
*
* However, using IONIC_DIRECTIVES will always *Just Work* with no
* performance overhead, so there is really no reason to not always use it.
*
* Pages have their content automatically wrapped in `<ion-view>`, so although
* you may see these tags if you inspect your markup, you don't need to include
* them in your templates.
*
* For more information on how pages are created, see the [NavController API reference](../../components/nav/NavController/#creating_pages)
*/
export
function
Page
(
config
:
PageMetadata
)
{
return
function
(
cls
)
{
config
.
selector
=
'ion-page'
;
config
.
directives
=
config
.
directives
?
config
.
directives
.
concat
(
IONIC_DIRECTIVES
)
:
IONIC_DIRECTIVES
;
config
.
host
=
config
.
host
||
{
}
;
config
.
host
[
'[hidden]'
]
=
'_hidden'
;
config
.
host
[
'[class.tab-subpage]'
]
=
'_tabSubPage'
;
var
annotations
=
_reflect
.
getMetadata
(
'annotations'
,
cls
)
||
[
]
;
annotations
.
push
(
new
Component
(
config
)
)
;
_reflect
.
defineMetadata
(
'annotations'
,
annotations
,
cls
)
;
return
cls
;
}
}
Back
|
FazBrowse Home
|
New Git URL