I am interested to know how can I embed the following TradingView\'s code to my Angular 8 project?
I could solve my problem like this:
tradingview
. Then I added the following code into the tradingview.component.ts
file:import { Component, OnInit, AfterViewInit } from '@angular/core'; declare const TradingView: any; @Component({ selector: 'app-tradingview', templateUrl: './tradingview.component.html', styleUrls: ['./tradingview.component.scss'] }) export class TradingviewComponent implements OnInit, AfterViewInit { constructor() { } ngOnInit() { } ngAfterViewInit(){ new TradingView.widget( { "width": 980, "height": 610, "symbol": "NASDAQ:AAPL", "timezone": "Etc/UTC", "theme": "Light", "style": "1", "locale": "en", "toolbar_bg": "#f1f3f6", "enable_publishing": false, "withdateranges": true, "range": "ytd", "hide_side_toolbar": false, "allow_symbol_change": true, "show_popup_button": true, "popup_width": "1000", "popup_height": "650", "no_referral_id": true, "container_id": "tradingview_bac65" } ); } }
Then I added following code into the tradingview.component.html
file:
<!-- TradingView Widget BEGIN -->
<div class="tradingview-widget-container">
<div id="tradingview_bac65"></div>
<div class="tradingview-widget-copyright"><a href="https://www.tradingview.com/symbols/NASDAQ-AAPL/" rel="noopener" target="_blank"><span class="blue-text">AAPL Chart</span></a> by TradingView</div>
<script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>
<script type="text/javascript">
</script>
</div>
<!-- TradingView Widget END -->
And seems it works fine!