forked from angular/angular
/
parsing-cases.ts
170 lines (148 loc) · 3.66 KB
/
parsing-cases.ts
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {Component, Directive, EventEmitter, Input, Output} from '@angular/core';
import {Hero} from './app.component';
@Component({
template: `
<h1>
Some <~{incomplete-open-lt}a~{incomplete-open-a} ~{incomplete-open-attr} text
</h1>`,
})
export class CaseIncompleteOpen {
}
@Component({
template: '<h1>Some <a> ~{missing-closing} text</h1>',
})
export class CaseMissingClosing {
}
@Component({
template: '<h1>Some <unknown ~{unknown-element}> text</h1>',
})
export class CaseUnknown {
}
@Component({
template: '<h1>{{data | ~{before-pipe}lowe~{in-pipe}rcase~{after-pipe} }}',
})
export class Pipes {
data = 'Some string';
}
@Component({
template: '<h1 h~{no-value-attribute}></h1>',
})
export class NoValueAttribute {
}
@Component({
template: '<h1 model="~{attribute-binding-model}test"></h1>',
})
export class AttributeBinding {
test: string = 'test';
}
@Component({
template: `
<h1 [model]="~{property-binding-model}test"></h1>
<h1 [model]="obj.~{data-binding-property-read}"></h1>`,
})
export class PropertyBinding {
test: string = 'test';
obj = {key: 'value'};
}
@Component({
template: '<h1 (model)="~{event-binding-model}modelChanged()"></h1>',
})
export class EventBinding {
test: string = 'test';
modelChanged() {}
}
@Component({
template: `
<h1 [(model)]="~{two-way-binding-model}test"></h1>
<input ~{two-way-binding-input}></input>`,
})
export class TwoWayBinding {
test: string = 'test';
}
@Directive({
selector: '[string-model]',
})
export class StringModel {
@Input() model: string = 'model';
@Output() modelChange: EventEmitter<string> = new EventEmitter();
}
@Directive({
selector: '[number-model]',
})
export class NumberModel {
@Input('inputAlias') model: number = 0;
@Output('outputAlias') modelChange: EventEmitter<number> = new EventEmitter();
}
interface Person {
name: string;
age: number;
street: string;
}
@Component({
template: `
<div *ngFor="let person of people | async">
{{person.~{async-person-name}name}}
</div>
<div *ngIf="promisedPerson | async as person">
{{person.~{promised-person-name}name}}
</div>
`,
})
export class AsyncForUsingComponent {
people: Promise<Person[]> = Promise.resolve([]);
promisedPerson: Promise<Person> = Promise.resolve({
name: 'John Doe',
age: 42,
street: '123 Angular Ln',
});
}
@Component({
template: `
<div #div>
<test-comp #test1>
{{~{test-comp-content}}}
{{test1.~{test-comp-after-test}name}}
{{div.~{test-comp-after-div}.innerText}}
</test-comp>
<div (click)="test1.~{event-binding-ref-property-read}"></div>
</div>
<test-comp #test2></test-comp>`,
})
export class References {
}
/*BeginTestComponent*/ @Component({
selector: 'test-comp',
template: '<div>Testing: {{name}}</div>',
})
export class TestComponent {
@Input('tcName') name = 'test';
@Output('test') testEvent = new EventEmitter();
} /*EndTestComponent*/
@Component({
templateUrl: 'test.ng',
})
export class TemplateReference {
title = 'Some title';
hero: Hero = {id: 1, name: 'Windstorm'};
heroes: Hero[] = [this.hero];
tupleArray: [string, Hero] = ['test', this.hero];
league: Hero[][] = [this.heroes];
heroesByName: {[name: string]: Hero} = {};
primitiveIndexType: {[name: string]: string} = {};
anyValue: any;
myClick(event: any) {}
}
@Component({
template: '{{~{empty-interpolation}}}',
})
export class EmptyInterpolation {
title = 'Some title';
subTitle = 'Some sub title';
}