question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AngularJS: one-time binding syntax

See original GitHub issue

Prettier 1.15.2 Playground link

--parser angular

Input:

<p>
  {{ ::vm.user }}
</p>

Output:

SyntaxError: Unexpected token :
    at o (https://prettier.io/lib/parser-angular.js:1:43175)
    at t.parseNgInterpolation (https://prettier.io/lib/parser-angular.js:1:44299)
    at n (https://prettier.io/lib/parser-angular.js:1:54796)
    at Object.t.parseInterpolation (https://prettier.io/lib/parser-angular.js:1:55134)
    at https://prettier.io/lib/parser-angular.js:1:55771
    at Object.parse (https://prettier.io/lib/parser-angular.js:1:55427)
    at Object.parse$2 [as parse] (https://prettier.io/lib/standalone.js:12931:19)
    at textToDoc (https://prettier.io/lib/standalone.js:15724:23)
    at https://prettier.io/lib/standalone.js:15712:14
    at Object.embed$2 [as embed] (https://prettier.io/lib/standalone.js:20444:55)

Expected behavior:

No error.

Notice that AngularJS and Angular aren’t the same framework. The one with JS is an older incompatible version. However, their expression syntaxes seem to be mostly compatible except for this one-time binding thing. Docs: https://docs.angularjs.org/guide/expression#one-time-binding

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ikatyangcommented, Nov 14, 2018

Note that syntax errors won’t be produced in child languages, this is a bug in our playground. Unknown syntax will be preserved if you’re using CLI.

Supporting a new syntax isn’t that simple, we need a parser for it (something like angular-estree-parser but for angular.js) since we don’t know what’s the difference between them, they look the same but we’re not sure, especially for edge cases.

And also I’m not sure if we should support angular.js, is it still developing not maintenance-only?

0reactions
thorn0commented, Dec 3, 2018

@icopp The syntax for filters/pipes is the same in AngularJS and Angular. Please prove me wrong if I am.

UPD yep, I was wrong, see #5586

Read more comments on GitHub >

github_iconTop Results From Across the Web

AngularJS one-time binding syntax - Ultimate Courses
One-time binding is very simple, from the docs: One-time expressions will stop recalculating once they are stable, which happens after the first ...
Read more >
angularjs - what is the difference between ng-bind vs one time ...
One-time binding is used for values that won't change after the page is stable. "Stable" generally means that the expression has been assigned...
Read more >
AngularJS: Performance Optimization with One-time Bindings
At a high-level, one-time data binding means that the template is rendered once based on the current $scope and then it never updates....
Read more >
AngularJS: Developer Guide: Expressions
The main purpose of one-time binding expression is to provide a way to create a binding that gets deregistered and frees up resources...
Read more >
One TIME binding. Make your Angular.Js applications…
Always use “::” syntax in the templates to unless you need binding on the property. The effect can be seen by using a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found