我完成了Angular2 / IONIC2应用程序的构建,iOS版本运行正常;但是,当我尝试在Android模拟器上运行同一页面时出现错误,当我在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模拟器上显示 ONLY ,当我在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'
})
答案 0 :(得分:0)
我猜ViewChildren(幻灯片)在这个阶段没有定义......
麦克