So the thing is: The html template of an angular component doesn't seem to be aware of the variable i set. Basically even if I set a variable in .ts class and then try to display it in a component, the view behaves as if there was no variable.

I've also tried creating a variable inside a tag but it just wouldn't work

TS The ts part of a component

export class <%component_name%> {
  bar = "test";
  constructor(){...}
} 

HTML The html part of a component

<div>
    <div>{{bar}}</div>
</div>

The result is:

Just in case: if I type a text inside the div without trying to display a variable, it works

HTML Result

Oh, just in case: logging the hello variable in constructor function does display it in console: click

besides, if I add an *ngIf referencing some boolean from the TS file like that:

TS

export class <%component_name%> {
  foo = true;
  bar = "test";
  constructor(){...}
} 

HTML

<div *ngIf="foo">
    <button>{{bar}}</button>
</div>

..then nothing at all is displayed.

At the end it's supposed to be a button with an icon and text on it, but i only get an icon on the button (Which is referenced inside the .html file)

If you have any idea of what might be going on, pls tell

0 Answers