-
Notifications
You must be signed in to change notification settings - Fork 26.2k
Template Expression Parsing Breaks When Using ES2015 Object Literal Properties Shorthand #10277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Binding syntax isn't supposed to support full ESx syntax. There are several other things that are not supported. |
It should not be too hard to add but don't expect this before or in 2.0 |
Hi, was this forgotten / ever coming? I know it's a very minor thing, but anything that makes writing templates even a bit cleaner is for the good. :) |
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends. Find more details about Angular's feature request process in our documentation. |
…mplates Adds support for shorthand property declarations inside Angular templates. E.g. doing `{foo, bar}` instead of `{foo: foo, bar: bar}`. Fixes angular#10277.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a ... (check one with "x")
Current behavior
HTML espression parsing throws an exception when using object literal shorthand syntax. When attempting to use this syntax, I get the following error.
<template [ngTemplateOutlet]="templateRef" [ngOutletContext]="{ item }"></template>
Throws:
EXCEPTION: Template parse errors: Parser Error: Missing expected : at column 8 in [{ item }] in App@4:47 (" <h2>{{_item}}</h2> </template> <template [ngTemplateOutlet]="templateRef" [ERROR ->][ngOutletContext]="{ item }"></template> "): App@4:47 VM9574 platform-browser.umd.js:1900 EXCEPTION: Template parse errors: Parser Error: Missing expected : at column 8 in [{ item }] in App@4:47 (" <h2>{{_item}}</h2> </template> <template [ngTemplateOutlet]="templateRef" [ERROR ->][ngOutletContext]="{ item }"></template> "): App@4:47BrowserDomAdapter.logError @ VM9574 platform-browser.umd.js:1900BrowserDomAdapter.logGroup @ VM9574 platform-browser.umd.js:1910ExceptionHandler.call @ VM9573 core.umd.js:4329(anonymous function) @ VM9573 core.umd.js:9844ZoneDelegate.invoke @ VM9533 zone.js:323onInvoke @ VM9573 core.umd.js:9100ZoneDelegate.invoke @ VM9533 zone.js:322Zone.run @ VM9533 zone.js:216(anonymous function) @ VM9533 zone.js:571ZoneDelegate.invokeTask @ VM9533 zone.js:356onInvokeTask @ VM9573 core.umd.js:9091ZoneDelegate.invokeTask @ VM9533 zone.js:355Zone.runTask @ VM9533 zone.js:256drainMicroTaskQueue @ VM9533 zone.js:474ZoneTask.invoke @ VM9533 zone.js:426 ...
Expected/desired behavior
Object literal shorthand parsing is supported. Ex. { foo } is equivalent to { foo: foo }.
Reproduction of the problem
If the current behavior is a bug or you can illustrate your feature request better with an example, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5).
https://plnkr.co/edit/J89FfkINlII9t3gaHG7J
What is the motivation / use case for changing the behavior?
This is valid object literal syntax, currently supported by transpilers and natively by evergreen browsers(Minus IE 10/11 and Safari 8).
Please tell us about your environment:
Other Information
In
@angular/compiler/expression_parser
, theparseLiteralMap() method of the _ParseAST class doesn't handle the literal shorthand syntax.
The text was updated successfully, but these errors were encountered: