组件(ts文件(如何访问索引中的变量.html? 示例:
内部:索引.html
<javascript>
var myVar = "test";
</javascript>
如何让这个变量"myVar"在组件页面中使用
例如在组件 html 上使用,如 {{myVar}}
在 ts 文件中,你可以这样声明它:
//Other imports
declare var myVar: any;
@Component({
selector: 'my-component',
templateUrl: './my-component.component.html',
styleUrls: ['./my-component.component.scss']
})
export class MyComponent {
my_javascript_variable = myVar;
}