在Angular 2(TypeScript)下面的代码给出了3以下的错误,如何解决它们.请建议.
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { NgModule, Component } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpModule, Http } from '@angular/http';
import 'rxjs/add/operator/map';
import { Observable } from "rxjs/Observable";
@Component({
selector: 'http-client',
template: `<h1>All Products</h1>
<ul>
<li *ngFor="let product of products">
{{product.title}}
</li>
</ul>
`})
class AppComponent {
products: Array<string> = [];
theDataSource: Observable;
constructor(private http: Http) {
this.theDataSource = this.http.get('api/products/')
.map(res => res.json());
}
ngOnInit() {
// Get the data from the …Run Code Online (Sandbox Code Playgroud) 我正在使用d3和d3-tip以及他们的@types,
"@types/d3": "^4.4.0",
"@types/d3-tip": "^3.5.2",
"d3": "^4.4.0",
"d3-tip": "^0.7.1",
Run Code Online (Sandbox Code Playgroud)
我有以下进口声明,
import * as d3 from 'd3';
Run Code Online (Sandbox Code Playgroud)
当尝试编译下面的打字稿代码时,得到以下错误,
var tip = d3.tip()
.attr('class', 'd3-tip')
.offset([-10, 0])
.html(function (d) {
return "<strong>Frequency:</strong> <span style='color:red'></span>";
})
Run Code Online (Sandbox Code Playgroud)
错误,
error TS2339: Property 'tip' does not exist on type 'typeof "C:/bugFix/WebPackPOC/src/WebPackApp/node_modules/@types/d3/index"'.
Run Code Online (Sandbox Code Playgroud) 我正在尝试通过单击按钮动态加载微调组件。
Plunker 链接在这里,
http://plnkr.co/edit/UEEQQRzX7RIkSO49rCHu?p=preview
let elementRef: ElementRef = this.appRef['_rootComponents'][0].location;
return this.startInside(elementRef, null);
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
elementRef.createComponent 不是函数。
请建议!