簡體   English   中英

Angular2-例外:TypeError:未定義不是函數

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM