Feature request: allow use of host property in @Component if values are strings
See original GitHub issueI would like a way to allow using the host property in component/directive decorators as long as the keys are being set to string
values. For example, this code:
@Component({
selector: 'my-component',
host: {
class: 'some-base-class some-modifier-class other-modifier-class'
}
})
class MyComponent {}
seems more readable than:
@Component({
selector: 'my-component'
})
class MyComponent {
@HostBinding('class.some-base-class')
someBaseClass = true;
@HostBinding('class.some-modifier-class')
someModifierClass = true;
@HostBinding('class.other-modifier-class')
otherModifierClass = true;
}
Issue Analytics
- State:
- Created 7 years ago
- Reactions:15
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Allow use of host property in @Component if intended values ...
I think it should be acceptable to use the host property in component/directive decorators as long as the keys are being set to...
Read more >Techniques to style component host element in Angular
Imagine a complex application where you want to implement a new feature, including new styles. If the styles aren't isolated, you will have...
Read more >Property binding - Angular
Use property binding to do things such as toggle button features, set paths programmatically, and share values between components.
Read more >Configuring Dispatcher | Adobe Experience Manager
You can use environment variables in string-valued properties in the ... HTTP or HTTPS request, it finds the virtual host value that best-matches...
Read more >Job definition parameters - AWS Batch
The following container properties are allowed in a job definition. ... If a maxSwap value of 0 is specified, the container doesn't use...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I disabled this lint rule since there is 0 argument for avoiding
host
when binding literals. I often bindtabindex
oraria-*
orole
up there. It makes much more sense than polluting the class with public stuff all over the place just to bind to the host. If we could have what the issue suggests, it would be useful again.It’s super annoying to have to create a boolean set to true, just to bind a static class to a component. It’s so much cleaner to use the host property for a static string binding. Really feels like I’m fighting the compiler to do something “the right way” and the compiler is forcing me to do it “the wrong way”.