0

In my component, I'm importing a constant and using it in the logic of my calculations. Both results work, producing the same outcome.

import { GlobalValue } from "src/app/models/constants";
@Component({ ... })
export class SomeComponent implements OnInit {

  constructor() { this localValue = GlobalValue; }

  private localValue: string = GlobalValue;

  ngOnInit() { ...
    const result1 = GlobalValue + 0;
    const result2 = localValue + 0;
  }
}

Then, I wished to use the constant in my HTML too. However, the following produces two different results. The local one works as expected while the reference to the global is empty. The page simply doesn't see the imported constant.

<div>{{localValue}}</div>
<div>{{GlobalValue}}</div>

Is there a way to make the template recognize the imported contant other than declaring/assigning a local proxy for it? How to, alterantively, why not?

Konrad Viltersten
  • 36,151
  • 76
  • 250
  • 438
  • 1
    You seem to have asked this once already, and accepted an answer: https://stackoverflow.com/questions/59447186/how-to-enable-constants-imported-into-component-in-the-template-without-proxy-vi – jonrsharpe Dec 28 '19 at 19:31
  • As I said on the previous attempt, the scope for the template is the public interface of the component class. – jonrsharpe Dec 28 '19 at 19:42

0 Answers0