【问题标题】:No component factory found Error in ionic2 rc0没有找到组件工厂 ionic2 rc0 中的错误
【发布时间】:2017-02-15 06:46:24
【问题描述】:

我正在尝试将 ionic2 中的 beta11 转换为 rc0。

我的一个页面有自定义标签作为挂钩 changelogs 我试图更新我的自定义标签,并且页面按照第 7 点解释

将每个自定义组件和管道导入并添加到 src/app/app.module.ts 中的声明数组。

我已将我的 componentTags.ts 文件移动到 src 并查看我的 @NgModel

@NgModule({
  declarations: [
    MyApp,
    LoginPage,
    HomePage,
    AboutUsPage,
    PrivacyPolicyPage,
    TermsOfUsePage,
    ProductSubCategoryPage,
    CategoryProductDetailsPage,
    CategoryProductDetailsInfoPage,

    //custom tags
    QuantityComponent
  ],
  imports: [
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    LoginPage,
    HomePage,
    AboutUsPage,
    PrivacyPolicyPage,
    TermsOfUsePage,
    ProductSubCategoryPage,
    CategoryProductDetailsPage,
    CategoryProductDetailsInfoPage,

    QuantityComponent
  ],
  //directives: [QuantityComponent],
  providers: [
    Products,
    Users,
    Configurator,
    Rest
  ]

这是我的自定义组件文件,名为 quantityTag.ts 文件

import {Component, Input, Output, EventEmitter} from '@angular/core';

@Component({
    selector: 'counter',
    
    styles: [`

        .quantity-input {
            display:flex; align-items:center;
        }
        .quantity-input .input-width {
            width:50px;
            border: 1px solid #bdbdbd;
            padding-top: 5px;
            
        }
        
        ion-icon{
            margin-left:0px;
            height:20px;
            padding-top: 3px;
            margin-top: 5px;
            color:#64c8dc;
            
        }
        button{
            background-color:SteelBlue;
        margin-left: 0px;
        }
    `],
    
    template: `
        <span class="quantity-input" style="">
            <input type="text" [(ngModel)]="counterValue" class="input-width"/> 
            <button small (click)="submit($event)"><ion-icon name="refresh"></ion-icon></button>
        </span>
    `
})

export class QuantityComponent {
    
    @Input() counterValue = 0;

    @Input() cookie = null;

    @Output() counterChange = new EventEmitter();

    submit(evt){
        this.counterChange.emit({
          value: this.counterValue,
          cookie: this.cookie
        });
    }



}

我有一个名为 shopingcart.ts 的页面,我需要这个自定义标签,但出现如下错误

例外:./HomePage 类 HomePage 中的错误 - 内联模板:18:27 原因:未找到 ShopingcartPage 的组件工厂

原始异常:找不到 ShopingcartPage 的组件工厂

【问题讨论】:

    标签: angular ionic2 angular2-components


    【解决方案1】:

    尝试在@NgModules 中添加您的页面

    app.module.ts:

    import { NgModule } from '@angular/core';
    import { IonicApp, IonicModule } from 'ionic-angular';
    import { MyApp } from './app.component';
    import { AboutPage } from '../pages/about/about';
    import { ContactPage } from '../pages/contact/contact';
    import { HomePage } from '../pages/home/home';
    import { TabsPage } from '../pages/tabs/tabs';
    import { LoginPage } from '../pages/loginpage/login-page'
    
    @NgModule({
      declarations: [
        MyApp,
        AboutPage,
        ContactPage,
        HomePage,
        TabsPage,
        LoginPage
      ],
      imports: [
        IonicModule.forRoot(MyApp)
      ],
      bootstrap: [IonicApp],
      entryComponents: [
        MyApp,
        AboutPage,
        ContactPage,
        HomePage,
        TabsPage,
        LoginPage
      ],
      providers: []
    })
    export class AppModule {}
    

    https://github.com/angular/angular/issues/11030

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-02
      • 1970-01-01
      • 2019-07-27
      • 2020-07-01
      • 2019-07-10
      • 2017-06-21
      • 2019-02-18
      • 1970-01-01
      相关资源
      最近更新 更多