Alright, this trick from "ASP.NET Core 2 and Angular 5" by Valerio De Sanctis surprised me. It's both novel and ghetto. If you have a class named something like redStop or greenGo and you put that in the class attribute of a selector tag, not only can you style the whole of the component as if a div wrapping the template markup were being styled, but you may also hand the redStop or greenGo magic string on as an Input that you may catch inside of the component and then perhaps react to in a case/switch statement. That's pretty nasty. Why not have a second property for the Input independent of the class? Doesn't that make for more readable code? Another surprise in all of this is that class doesn’t have to be wrapped in square brackets inline in the selector tag as is normally the situation with Inputs. Wacky!
No comments:
Post a Comment