Skip to content

I cannot use calc with @HostBindings #13691

@jrgleason

Description

@jrgleason

I'm submitting a ... (check one with "x")

[X] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
this works

    @HostBinding('style.top')
    private readonly TOP = "100%";

But this does not...

    @HostBinding('style.top')
    private readonly TOP = "calc( 100% + 2px )";

Expected behavior

The calc would succeed and I would see the top value set in the dev tools

Minimal reproduction of the problem with instructions

https://plnkr.co/edit/LD6KRQ5ofWOIYWKNzktc?p=preview

What is the motivation / use case for changing the behavior?

Since there is no other good way to set styles on directives I need a way to set a height based on calc. I have tried some hacking with the nativeElementRef but with only limited success. It seems that if the browser supports this behavior @HostBinding should too

Please tell us about your environment:

Webpack, Angular2

  • Angular version: 2.0.X

  • Browser: [all]

  • Language: [all]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions