question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

interpolation not working properly while dynamically change value

See original GitHub issue

🐞 bug report

interpolation throws error while dynamically change value

Description

I have tried to update value dynamically using interpolation but it throws below error:

I have created components like below :

import { Component, ViewEncapsulation} from '@angular/core';
 
@Component({
 selector: 'app-root',
 templateUrl: 'app.component.html',
 styleUrls: ['app.component.css'],
 encapsulation: ViewEncapsulation.None
})
 
export class AppComponent {
 constructor() { }
 public rtedataSource: string = "<p>One</p>";
 checkRTE(){
 this.rtedataSource ="asffsdffsf"
 }
}

Error:

MicrosoftTeams-image

πŸ”¬ Minimal Reproduction

  1. Download below sample: Angular_issue.zip

  2. give below commands

npm i

ng serve

πŸ”₯ Exception or Error

But if i use changeDetection: ChangeDetectionStrategy.OnPush, it doesn’t throws any error and interpolation working fine.

Reference code:

import { Component, ViewEncapsulation, ChangeDetectionStrategy, ChangeDetectorRef} from'@angular/core';
 
@Component({
selector:'app-root',
templateUrl:'app.component.html',
styleUrls: ['app.component.css'],
encapsulation:ViewEncapsulation.None,
changeDetection:ChangeDetectionStrategy.OnPush
})
 
exportclassAppComponent {
constructor(privateref:ChangeDetectorRef) {
ref.detach();
setInterval(() => { this.ref.detectChanges(); }, 100);
 }
publicrtedataSource:string="<p>One</p>";
checkRTE(){
this.rtedataSource="asffsdffsf"
 }
}

🌍 Your Environment

Angular Version:




Angular CLI: 7.0.3
Node: 8.9.3
OS: win32 x64
Angular:
...

 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.10.3
@angular-devkit/core         7.0.3
@angular-devkit/schematics   7.0.3
@schematics/angular          7.0.3
@schematics/update           0.10.3
rxjs                         6.3.3
typescript                   3.1.3

Anything else relevant?

I just want to know why this happening?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mlc-mlapiscommented, Jul 17, 2019
1reaction
mlc-mlapiscommented, Jul 17, 2019

@kumaresan-subramani OK, from that simple demo it was not clear. If you know the reason why didn’t you explain it? And what do you expect now? Do you think that somebody would analyze how <ejs-tooltip> component is working, which timeline is exactly using and so on?

If it is a real Angular problem then demonstrate it using the pure code without using any libs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ngClass with string interpolation to dynamically change it
I need to change with variables the classes applied to a div, but not all. In the following example I need a class...
Read more >
Developer Guide: Interpolation - AngularJS: API
Dynamically changing an interpolated value. You should avoid dynamically changing the content of an interpolated string (e.g. attribute value or text node).
Read more >
Python string interpolation (Make Dynamic Strings) - Like Geeks
In this tutorial, you'll learn about Python string interpolation by: concatenation, the modulo operator, the format method, Using f-strings,Β ...
Read more >
[Solved]-Angular 6 String Interpolation not updating with value ...
Coding example for the question Angular 6 String Interpolation not updating with value inside .subscribe()-angular.js.
Read more >
String interpolation - C# tutorial - Microsoft Learn
One or more interpolation expressions. An interpolation expression is indicated by an opening and closing brace ( { and } ). You can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found