我在尝试离开MyComponent时出现此错误,似乎是在ngOnDestroy()上触发的:
Error: Uncaught (in promise): EXCEPTION: Error in /client/+multi-project/pm/ny-pm-tracker-details/ny-pm-tracker-details.component.html:10:12
ORIGINAL EXCEPTION: TypeError: Cannot read property 'length' of undefined
ORIGINAL STACKTRACE:
TypeError: Cannot read property 'length' of undefined
at TrackerAsideComponent.MeteorComponent.ngOnDestroy (http://localhost:3000/packages/modules.js?hash=6111b8d7b4df6b0c758550c26446f0559a271ad2:76641:55)
at DebugAppView._View_NyPmTrackerDetailsComponent0.destroyInternal (NyPmTrackerDetailsComponent.template.js:177:35)
at DebugAppView.AppView.destroyLocal (http://localhost:3000/packages/modules.js?hash=6111b8d7b4df6b0c758550c26446f0559a271ad2:11632:14)
at DebugAppView.destroyLocal (http://localhost:3000/packages/modules.js?hash=6111b8d7b4df6b0c758550c26446f0559a271ad2:11767:43)
at DebugAppView.AppView._destroyRecurse (http://localhost:3000/packages/modules.js?hash=6111b8d7b4df6b0c758550c26446f0559a271ad2:11621:14)
at DebugAppView.AppView._destroyRecurse (http://localhost:3000/packages/modules.js?hash=6111b8d7b4df6b0c758550c26446f0559a271ad2:11619:25)
at DebugAppView.AppView.destroy (http://localhost:3000/packages/modules.js?hash=6111b8d7b4df6b0c758550c26446f0559a271ad2:11607:14)
at ComponentRef_.destroy (http://localhost:3000/packages/modules.js?hash=6111b8d7b4df6b0c758550c26446f0559a271ad2:10280:82)
at RouterOutlet.unload (http://localhost:3000/packages/modules.js?hash=6111b8d7b4df6b0c758550c26446f0559a271ad2:21662:22)
at _LoadSegments.unloadOutlet (http://localhost:3000/packages/modules.js?hash=6111b8d7b4df6b0c758550c26446f0559a271ad2:19276:24)
我检查mycomponent的第10行是这样的:
<div class="col-sm-3">
<th-tracker-aside <======This would be line 10
[currentList]="currentList"
(selectItem)="onSelectItem($event)">
</th-tracker-aside>
</div>
所以我去了跟踪器 - 看起来像这样:
<aside class="th-aside-list th-tracker-aside th-section-bordered animated fadeIn">
<div class="th-aside-header-wrapper">
<h3>Navigate by</h3>
<select (change)="onChange($event.target.value)">
<option *ngFor="let navItem of _trackerService.navigateByList">{{navItem}}</option>
</select>
</div>
<div class="th-search-wrapper">
<md-input>
<span md-prefix><i class="fa fa-search th-search-icon" aria-hidden="true"></i></span>
</md-input>
</div>
<div class="th-aside-list-wrapper">
<div>
<h3>
All {{_trackerService.navigateByLabel}} <span
class="th-gray-text">(#####)</span>
</h3>
</div>
<ul>
<li *ngFor="let item of _trackerService.currentList"
(click)="changeSelectedItem(item)">
{{item.text}}
</li>
</ul>
</div>
一切正常,除非点击链接到视图之外。
答案 0 :(得分:0)
当我从子视图中删除extends MeteorComponent
时,问题似乎已得到解决。