-
Notifications
You must be signed in to change notification settings - Fork 27.4k
[$parse:syntax] Syntax Error: Token ':' is an unexpected token (ngForm) #13771
Comments
Oh, Java you so silly. |
Ok, so that's not the cause after all. I think we need expert guidance here. @lgalfaso do you have an idea how to solve this? We could re-introduce the old setter helper, but maybe there's a better way. |
what do you mean? That the colon is not the problem? I'll take another look into it then tomorrow to find out what it could be then instead. The error definitely happens only on some forms and not for every form. |
The colon is definitely the problem. I was just wrong about how to fix it.
|
ok thanks. And yeah, java is silly. :) Admittedly, you can change the separator char to something other, but its so rarely done that a lot of code just assumes the colon. So yeah, it would be quite hard to do that. |
Hi, I am not able to find an easy way. |
The thing is that it worked before, no? Before we allowed interpolated form names, this kind of name was allowed. It was just using a different kind of setter: https://github.com/angular/angular.js/blob/v1.3.x/src/ng/parse.js#L838 |
@Narretz the previous behavior was very very strange. Eg, for |
@lgalfaso Your suggestion per se would not be possible as the server framework is rebuilding server state out of the id/name so elements need to have persistent id and name attributes. But I have now a (somewhat) ugly solution with 2 directives: one with a high priority which changes the name attribute for the ngForm directive. And another directive with low priority during link time which changes it back to the original name. It works for me, but its not ideal. |
Looks like we have to live with this then, and add a BC notice to the changelog. |
@marcorinck if you are not using the angular This would be, to change 1 and 2 |
@lgalfaso so you suggestion would mean that @marcorinck would need to add a |
Here is an alternate workaround which modifies the http://plnkr.co/edit/VuHgBr5EQHTLJrk0HEVC?p=preview You could make this more clever by checking for some other attribute on the element that the server might attach... |
@petebacondarwin if you are going to change |
Here is a more robust example: http://plnkr.co/edit/414QyUt32eZ129kJeJik?p=preview |
With these workarounds, and the difficulty in restoring the previous behavior, should I add this to the CL / migration guide and close this afterwards? |
I think so. It was really a bug in the old parser. |
@petebacondarwin If you actually need the original form name, for example for server-side form submission, you still need to change the form name back to what it was, for example in a postLink fn. |
Good point
|
hi, i ran into the same problem with Salesforce on the back end side. In my case I did not want Angular to mess with the form that Visualforce created at all. My solution was therefore to tell Angular to ignore the form in question all together:
Notes:
Source: |
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:
When bootstrapping this without any manual directives or controllers angularjs 1.4.8 is throwing an error:
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?
The text was updated successfully, but these errors were encountered: