- 我是新来的typescript和angular js。
- 我试图在我的代码中包含另一个组件代码。
- 这是baby.js代码到我的代码
- 但我得到一个错误。 TypeError:无法读取未定义的属性'tigerStart'
- 可以告诉我如何解决它。
- 提供下面
TypeError: Cannot read property 'tigerStart' of undefined
at init.open (pen-pencil.ts:1270)
at init.trigger (kendo.all.min.js:25)
at init.open (kendo.all.min.js:45)
at Penguin.openPopup (pen-pencil.ts:1286)
at penguin.pencilClicked (headset.ts:689)
at _View_penguin4._handle_click_45_0 (penguin.ngfactory.js:4087)
at eval (core.umd.js:9698)
at eval (platform-browser.umd.js:1877)
at eval (platform-browser.umd.js:1990)
at ZoneDelegate.invoke (zone.js:203)
我的代码包括tigerStart方法成整体js代码typeError:无法读取undefined属性'tigerStart'
@ViewChild(体育)公共天空:运动;
that.window = $("#PenguinPopup");
that.window.kendoWindow({
width: "60%",
title: false,
visible: false,
resizable: false,
actions: [],
draggable: false,
modal: true,
open: function() {
$("html, body").css("overflow", "hidden");
that.isVisible = true;
$('.kPopUpTitle').html(values.title);
this.sky.tigerStart();
包括鱼类组件到我的HTML
<div class="clearFloat"></div>
<ul class="kendu-custom-contextmenu" id="context-menuFinancialSearch">
<li class="kPopUpBtnTriple">View Details</li>
<li class="kPopUpBtnTriple">Manage Documents</li>
</ul>
<financeLeftSlider (savedSearchData)='getSaveEvent($event)'></financeLeftSlider>
<Fish></Fish>
<Penguin (documentCount)='getDocumentEvent($event)'></Penguin>
<sports></sports>
<div class="searchNameRequiredPopup">
<div class="pipepobUpBox pipeWindow kPopupConfirmationBox">
<div class="row pipePopUpGridCollection pipePopUpContent lineHeightInputs">
<div class="pipeContent">Please enter the search name.</div>
</div>
<div class="clearFloat"></div>
<div class="row pipePopUpFooter textAligncenterImp">
<!-- <button class="commonBtn" type="button" id ="deleteDocumentYes">Yes</button> -->
<button class="clearBtn" type="button" id="searchNameRequiredBtn">Ok</button>
</div>
<div class="clearFloat"></div>
</div>
</div>
baby.html
<div id="baby"></div>
<div id="baby1"></div>
baby.js
@Component({
moduleId: module.id,
selector: 'sports',
templateUrl: 'sports.html'
})
export class Star {
tigerStart(): void {
kendo.ui.sky($("#baby"), true);
}
tigerEnd(): void {
kendo.ui.sky($("#baby"), false);
}
tigerStart1(): void {
kendo.ui.sky($("#baby1"), true);
}
tigerEnd1(): void {
kendo.ui.sky($("#baby1"), false);
}
}
- 当我打印这张图时,我没有看到天空,所以我阅读了中型表格,并试图用胖箭头进行绑定,但仍然无法完成它。
- 在视图中,我正在使用运动的孩子
- 你能告诉我如何解决它。
- 以便为今后这将有助于
https://medium.com/@thejasonfile/es5-functions-vs-es6-fat-arrow-functions-864033baa1a
@ViewChild(sports) public sky: sports;
**- tried with fat arrow**
open:() => {
**- tried with bind**
this.sky.tigerStart().bind(this);
感谢您的回复。 - 当我打印这张照片时,我没有看到天空,所以我阅读了介质表格,并尝试着用箭头和箭头进行绑定,但仍然无法完成。 - 在视图中,我正在使用运动 - 你能告诉我如何解决它。 - 以便将来有帮助 –
https://medium.com/@thejasonfile/es5-functions-vs-es6-fat-arrow-functions-864033baa1a @ViewChild(sports)public sky:sports; open:()=> { this.sky.tigerStart()。绑定(本); –
我读过你引用的文章。有趣。我不知道ES6“胖箭头”以这种方式保留了“这个”范围。但无论如何,你所做的改变已经让事情变得糟糕。你调用绑定,但在那一行,现在已经太晚了,因为你已经在函数中。你没有真正给我足够的信息来解决你的问题。我只能猜测。我会尝试更新我的答案,您可以尝试查看它是否适合您。 – ultramoka