Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

[$parse:syntax] Syntax Error: Token ':' is an unexpected token (ngForm) #13771

Closed
@marcorinck

Description

@marcorinck

I have an issue updating angular.js from 1.3.20 to 1.4.8 for an internal project which I can't reproduce on a simple jsfiddle. The error is happening since 1.4.4, its working without any problem til 1.4.3

The project is using JSF (java framework) which is automatically generating IDs and name attributes with a colon in it, something like this:

<form id="permanentFilter:closeFilterForm" name="permanentFilter:closeFilterForm" method="post" action="/liste/uebersicht.jsf?windowId=072" class="navbar-form navbar-right" enctype="application/x-www-form-urlencoded">
</form>

When bootstrapping this without any manual directives or controllers angularjs 1.4.8 is throwing an error:

Error: [$parse:syntax] Syntax Error: Token ':' is an unexpected token at column 16 of the expression [permanentFilter:closeFilterForm] starting at [:closeFilterForm].
http://errors.angularjs.org/1.4.8/$parse/syntax?p0=%3A&p1=is%20an%20unexpec…d%20token&p2=16&p3=permanentFilter%3AcloseFilterForm&p4=%3AcloseFilterForm
    at http://127.0.0.1:8080/resources/javascript/external-libs/angular.js:68:12
    at Object.AST.throwError (http://127.0.0.1:8080/resources/javascript/external-libs/angular.js:13100:11)
    at Object.AST.ast (http://127.0.0.1:8080/resources/javascript/external-libs/angular.js:12870:12)
    at Object.ASTCompiler.compile (http://127.0.0.1:8080/resources/javascript/external-libs/angular.js:13319:31)
    at Parser.parse (http://127.0.0.1:8080/resources/javascript/external-libs/angular.js:14189:29)
    at $parse (http://127.0.0.1:8080/resources/javascript/external-libs/angular.js:14291:39)
    at getSetter (http://127.0.0.1:8080/resources/javascript/external-libs/angular.js:20608:14)
    at ngFormPreLink (http://127.0.0.1:8080/resources/javascript/external-libs/angular.js:20579:37)
    at invokeLinkFn (http://127.0.0.1:8080/resources/javascript/external-libs/angular.js:8841:9)
    at nodeLinkFn (http://127.0.0.1:8080/resources/javascript/external-libs/angular.js:8314:11)

Its throwing the error for every form which has a colon, its working with every form which has an ID/name without a colon.
Since angularjs 1.4.4 ngForm directive is automatically creating expressions from name attributes which is causing this problem as the colon is confusing the parser. (function getSetter(expression) on line 20442 in unmodified angularjs 1.4.4)

Is there any solution to that on the angularjs side?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions