![](/img/trans.png)
[英]Callback generates “TypeError: this is undefined” in Angular2/Firebase
[英]Angular2 - EXCEPTION: TypeError: undefined is not a function
我完成了Angular2 / IONIC2应用的构建,iOS版本运行良好; 但是,当我尝试在Android Simulator上运行同一页面时出现错误时,当我在CHROME上检查正在运行的应用程序时能够得到它:
EXCEPTION: TypeError: undefined is not a function
browser_adapter.js:77 EXCEPTION: TypeError: undefined is not a function
browser_adapter.js:77 STACKTRACE:
browser_adapter.js:77 TypeError: undefined is not a function
at new DishesComponent (file:///android_asset/www/build/js/app.bundle.js:1746:49)
at AppView._View_MenuPage2.createInternal (MenuPage.template.js:354:31)
at AppView.create (file:///android_asset/www/build/js/app.bundle.js:33434:21)
at TemplateRef_.createEmbeddedView (file:///android_asset/www/build/js/app.bundle.js:33335:14)
at ViewContainerRef_.createEmbeddedView (file:///android_asset/www/build/js/app.bundle.js:33844:35)
at NgFor._bulkInsert (file:///android_asset/www/build/js/app.bundle.js:4250:50)
at NgFor._applyChanges (file:///android_asset/www/build/js/app.bundle.js:4206:14)
at NgFor.ngDoCheck (file:///android_asset/www/build/js/app.bundle.js:4188:22)
at AppView._View_MenuPage0.detectChangesInternal (MenuPage.template.js:225:42)
at AppView.detectChanges (file:///android_asset/www/build/js/app.bundle.js:33581:14)
记录下来,该问题仅出现在android模拟器上,当我在Chrome(MAC)上运行它时,一切正常。 模拟我正在使用Android 5.1
我没有在真正的设备上尝试过,但是我想结果应该是一样的。
经过一番挖掘,我找到了引起问题的那条线,但是我无法解决!
我将分享导致问题的内容:
page1.html
<ion-slides id="dishes-content" class="dishes-slides" (ionWillChange)="onCategoryChanged($event.activeIndex)">
<ion-slide *ngFor="let category of categories; let i = index">
//When I remove the below line, the issue disappears!!
//This is a directive imported from finalMenu
<dishes [categoryValue]="category" [cart]="cart"></dishes>
</ion-slide>
</ion-slides>
page1.js
@Component({
templateUrl: 'build/pages/page1/page1.html',
directives: [DishesComponent],
queries: {
sliders: new ViewChildren(Slides)
}
})
finalmenu.js
@Component({
selector: 'dishes',
inputs: ['categoryValue', 'cart'],
templateUrl: 'build/pages/finalmenu/finalmenu.html'
})
我想在这个阶段还没有定义ViewChildren(Slides)...
麦克风
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.