Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

655
Views
Warning: SafeValue must use [property]=binding

I'm trying to send an element getBoundingClientRect() to my component this way:

<object [fromTop]="element.getBoundingClientRect().top"></object>

In my component html I do this since I got a note that it was "unsafe"

this.fromTop = this.sanitizer.bypassSecurityTrustStyle(this.fromTop);

<div
style="position:absolute;top:{{fromTop}}px;">Top:{{fromTop}}</div>

But after adding the sanitizer I get the following message:

SafeValue must use [property]=binding:

What's wrong? How I can let my object be in an absolute position that equals to top: {{fromTop}}px?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

{{}} is for string binding only. A sanitized value is not a plain string anymore and if you use {{}} the sanitization marker is removed.

You need to sanitize the whole style value and then bind it to [style]="..."

but a more angulary way would be using Angular bindings or directives

<div [style.top.px]="fromTop" [style.position]="'absolute'">Top:{{fromTop}}</div>

<div [ngStyle]="{top: fromTop + 'px', position: 'absolute'}">Top:{{fromTop}}</div>

This way no sanitization is required.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!