将Tradingview嵌入Angular 5 [英] Embed Tradingview into Angular 5
本文介绍了将Tradingview嵌入Angular 5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是将函数复制到此处的嵌入脚本中( https://www.tradingview .com/widget/advanced-chart/)添加到我的Angular 5应用中的组件中,并将源脚本包含在angular-cli.json中.但是,该组件返回错误找不到名称'TradingView'".有人有什么建议吗?
I just copy the function in the embed script found here (https://www.tradingview.com/widget/advanced-chart/) into a component in my Angular 5 app, and include the source script in angular-cli.json. However, the component returns error "Cannot find name 'TradingView'". Someone has any suggestions?
推荐答案
我找到了一种通过在组件中声明TradingView
来解决编译错误的方法:
I found a way to solve the compile error by declaring TradingView
in component:
declare const TradingView: any;
export class ChartComponent implements AfterViewInit {
ngAfterViewInit() {
new TradingView.widget({
'container_id': 'technical-analysis',
'autosize': true,
'symbol': this.symbolPair,
'interval': '120',
'timezone': 'exchange',
'theme': 'Dark',
'style': '1',
'toolbar_bg': '#f1f3f6',
'withdateranges': true,
'hide_side_toolbar': false,
'allow_symbol_change': true,
'save_image': false,
'hideideas': true,
'studies': [
'MASimple@tv-basicstudies' ],
'show_popup_button': true,
'popup_width': '1000',
'popup_height': '650'
});
}
}
查看:
<div id="technical-analysis"></div>
这篇关于将Tradingview嵌入Angular 5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文