diff --git a/modules/@angular/compiler/src/ml_parser/icu_ast_expander.ts b/modules/@angular/compiler/src/ml_parser/icu_ast_expander.ts
index 88745078fa..9826152631 100644
--- a/modules/@angular/compiler/src/ml_parser/icu_ast_expander.ts
+++ b/modules/@angular/compiler/src/ml_parser/icu_ast_expander.ts
@@ -106,6 +106,13 @@ function _expandDefaultForm(ast: html.Expansion, errors: ParseError[]): html.Ele
const expansionResult = expandNodes(c.expression);
errors.push(...expansionResult.errors);
+ if (c.value === 'other') {
+ // other is the default case when no values match
+ return new html.Element(
+ `template`, [new html.Attribute('ngSwitchDefault', '', c.valueSourceSpan)],
+ expansionResult.nodes, c.sourceSpan, c.sourceSpan, c.sourceSpan);
+ }
+
return new html.Element(
`template`, [new html.Attribute('ngSwitchCase', `${c.value}`, c.valueSourceSpan)],
expansionResult.nodes, c.sourceSpan, c.sourceSpan, c.sourceSpan);
diff --git a/modules/@angular/compiler/test/ml_parser/icu_ast_expander_spec.ts b/modules/@angular/compiler/test/ml_parser/icu_ast_expander_spec.ts
index e216462e32..2d015f42e3 100644
--- a/modules/@angular/compiler/test/ml_parser/icu_ast_expander_spec.ts
+++ b/modules/@angular/compiler/test/ml_parser/icu_ast_expander_spec.ts
@@ -82,14 +82,17 @@ export function main() {
});
it('should handle other special forms', () => {
- const res = expand(`{person.gender, gender,=male {m}}`);
+ const res = expand(`{person.gender, select, male {m} other {default}}`);
expect(humanizeNodes(res.nodes)).toEqual([
[html.Element, 'ng-container', 0],
[html.Attribute, '[ngSwitch]', 'person.gender'],
[html.Element, 'template', 1],
- [html.Attribute, 'ngSwitchCase', '=male'],
+ [html.Attribute, 'ngSwitchCase', 'male'],
[html.Text, 'm', 2],
+ [html.Element, 'template', 1],
+ [html.Attribute, 'ngSwitchDefault', ''],
+ [html.Text, 'default', 2],
]);
});
diff --git a/modules/@angular/compiler/test/template_parser/template_parser_spec.ts b/modules/@angular/compiler/test/template_parser/template_parser_spec.ts
index 8cb15dee05..c2551f716b 100644
--- a/modules/@angular/compiler/test/template_parser/template_parser_spec.ts
+++ b/modules/@angular/compiler/test/template_parser/template_parser_spec.ts
@@ -1787,18 +1787,18 @@ The pipe 'test' could not be found ("[ERROR ->]{{a | test}}"): TestComp@0:0`);
const shortForm = '{ count, plural, =0 {small} many {big} }';
const expandedForm = '' +
'small' +
- 'big' +
- '';
+ 'big' + i
+ '';
expect(humanizeTplAst(parse(shortForm, [
]))).toEqual(humanizeTplAst(parse(expandedForm, [])));
});
- it('should expand other messages', () => {
- const shortForm = '{ sex, gender, =f {foo} other {bar} }';
+ it('should expand select messages', () => {
+ const shortForm = '{ sex, select, female {foo} other {bar} }';
const expandedForm = '' +
- 'foo' +
- 'bar' +
+ 'foo' +
+ 'bar' +
'';
expect(humanizeTplAst(parse(shortForm, [