angular icon indicating copy to clipboard operation
angular copied to clipboard

Strange behavior of template parsing depending on attributes order

Open aalexelis opened this issue 10 years ago • 7 comments

Hello, I don't know if this is part of the template parser specs, but it seems that attributes order affects parsing. In the The Basics example on the top page, in src/hello_world.html, if one replaces:

<input type="text" [(ngModel)]="yourName" placeholder="Enter a name here">

for

<input placeholder="Enter a name here" [(ngmodel)]="yourName" type="text">

the parser cannot parse the ngModel property

aalexelis avatar Jan 11 '16 10:01 aalexelis

It looks like you need to wrap some code in ```

zoechi avatar Jan 11 '16 10:01 zoechi

In your second use case (<input placeholder="Enter a name here" [(ngmodel)]="yourName" type="text">) the ngmodel is lower-cased - I don't know if this is intentional or not, but new HTML parser is case sensitive when it comes to property names.

I don't know if this is your exact problem since you are not giving details on:

the parser cannot parse the ngModel property

What does it mean exactly? Are you getting any error on the console? Bad runtime behavior? Putting together a plunker with a reproduce scenario would give us those details.

pkozlowski-opensource avatar Jan 11 '16 10:01 pkozlowski-opensource

sorry for mistyping, does not work with ngModel too. Plunker: http://plnkr.co/edit/6D0bb7CCnGSFDp1Xw5Kh?p=preview

it gives:

EXCEPTION: Template parse errors:
Can't bind to 'ngΜodel' since it isn't a known native property ("data-bind to the input element; store value in yourName -->
<input placeholder="Enter a name here" [ERROR ->][(ngΜodel)]="yourName" type="text">
<hr>
<!-- conditionally display `yourName` -->
"): HelloWorld@2:39

aalexelis avatar Jan 11 '16 10:01 aalexelis

Your "M" character has some funny encoding. Could it be your keyboard layout?

Edit: try re-typing the M using your code editor

pietie avatar Jan 11 '16 11:01 pietie

@pietie thanks for the reply ( I am a Greek living in Japan, sometimes encodings do get out of hand )

copying/pasting from you did not fix the problem, but I copied from the original plunker, shuffled the attributes and it seems to work fine, so it must not be the attributes order problem, as I initially supposed, sorry about alarming you.

Will keep trying to figure this out, thanks

aalexelis avatar Jan 11 '16 12:01 aalexelis

@pkozlowski-opensource, @pietie thanks for your help, I finally figured it out, the problem was on my side, not of the parser, sorry for this. (basically, the core cause was as @pkozlowski-opensource rightly pointed out that the parser is case-sensitive, while my Html parser/writer turns everything to lowercase. Any way to tackle this?)

I am closing this issue.

aalexelis avatar Jan 11 '16 14:01 aalexelis

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.