As far I can read the documentation there's only public
and private
as scopes in TypeScript. However, when I attempt the following exercise, I get different results, as if the variable environment
isn't visible to the markup unless declared (publicly or privately).
<div class="text-section">
Name is: {{environment.shazoo}}.
</div>
import { environment } from "../../../../environments/environment";
...
@Component({ ... })
export class DemoComponent implements OnInit {
constructor(private builder: FormBuilder) { ... }
...
private environment = environment;
}
The above example results in the text hazaa being displayed. However, if I comment out the line assigning the imported environment instance to the locally declared one, the text vanishes.
import { environment } from "../../../../environments/environment";
...
@Component({ ... })
export class DemoComponent implements OnInit {
constructor(private builder: FormBuilder) { ... }
...
// private environment = environment;
}
The way I figure, if the imported instance is visible in the code but not in the markup, there's a third level of scoping, whatever that might be (some kind of secludedly private thingy). But I hardly think that it's the case in reality. What am I missing?