【发布时间】:2017-07-07 14:51:53
【问题描述】:
我有一个应用程序使用:
- 角度 2
- 用于可视化的 GoJS
它包括:
-
父组件:
src/app/search.component.ts它由一个搜索栏和一些对服务器的 API 调用将显示按钮的区域组成。
-
子组件:
src/app/search-details.component.ts它由一个
<div>组成,它体现了GoJS Radial Layout Diagram
在子组件的SearchDetailsComponent 类中,有一个名为nodeClicked 的简单函数,如下所示:
nodeClicked(e, node) {
// show the name of the clicked node on the console
console.log(node.data.text);
this.checkString = node.data.text // HERE is the ERROR....
}
每次渲染图表并且用户单击任何节点时,都会出现错误说明:
类型错误:这是未定义的
Stack-Trace:
execute/SearchDetailsComponent</SearchDetailsComponent.prototype.nodeClicked@http://run.plnkr.co/L7H44HHRrMceJAkj/src/app/search-details.component.ts!transpiled:96:21
Vh@https://unpkg.com/gojs/release/go-debug.js:539:43
Vg.prototype.standardMouseClick@https://unpkg.com/gojs/release/go-debug.js:537:201
ek.prototype.doMouseUp@https://unpkg.com/gojs/release/go-debug.js:667:73
E.prototype.doMouseUp@https://unpkg.com/gojs/release/go-debug.js:802:92
Ll/a.no@https://unpkg.com/gojs/release/go-debug.js:1012:149
ZoneDelegate.prototype.invokeTask@https://unpkg.com/zone.js/dist/zone.js:424:17
onInvokeTask@https://unpkg.com/@angular/core/bundles/core.umd.js:3956:28
ZoneDelegate.prototype.invokeTask@https://unpkg.com/zone.js/dist/zone.js:423:17
Zone.prototype.runTask@https://unpkg.com/zone.js/dist/zone.js:191:28
ZoneTask/this.invoke@https://unpkg.com/zone.js/dist/zone.js:486:28
这里所指的this是SearchDetailsComponent类中声明的checkString变量。
checkString 无法识别怎么办?我已经在上面定义了。每次单击节点时我希望调用 API 服务 并且也调用 HTTP GET 时,此错误不断出现。
我在这里做错了什么?
Live Plunker
Embed Plunker
【问题讨论】: