Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
820 views
in Technique[技术] by (71.8m points)

compilation - In angular 10, different results while compiling the same HTML tags with ngstyle and others directives?

I have this code, in .html

<div style="float:left ;" [ngStyle]="{'width.%': CurrentRankPercent, 'height.px': 5}"></div>

The above code compiles ok.

then I add the follow: , 'background-color': 0xFF

        <div style="float:left ;" [ngStyle]="{'width.%': CurrentRankPercent, 'height.px': 5, 'background-color': 0xFF }"></div>

It compiles wrong, so, I press CTRL-Z, to undo all changes (and then I just add and remove an useless space anywhere else so it is like the file surelly is taken as changed), save all menú option (last visual studio code), and then see how it compiles,

Now, the code that before was compiling OK, now COMPILES ERROR (Yes, I checked that the CMD console really is alive and re-runing the compilation process and not stuck in text select mode), don't matter how many times I try to recompile it, it throws errors.

So, I press, CTRL+C, YES, and write again, ng serve -o (windows)

and it now compiles, ok!.

What I am doing wrong? This is turning me crazy. It is like a new-developers trap?

The errors are: Parser Error: Missing expected } at column..., but there is the closing...

But in the following compilations for the SAME code, returns " Can't bind to 'ngStyle' since it isn't a known property of 'div'.", which is a lie, because Common is imported, worked the first time, etc.

so, CTRL+C , YES, and ng serve -o, again , again and again.

Also I don't know, why : 255 works, and : 0xFF doesn't work? I am assuming ngStyle is expecting typescript lang. not normal CSS as the sharp #FF didn't work.

question from:https://stackoverflow.com/questions/65896654/in-angular-10-different-results-while-compiling-the-same-html-tags-with-ngstyle

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...