gpt4 book ai didi

angular - ionic2 rc0 中找不到组件工厂错误

转载 作者:太空狗 更新时间:2023-10-29 18:03:13 24 4
gpt4 key购买 nike

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

我的一个页面有自定义标签作为 Hook changelogs我试图按照第 7 点的解释更新我的自定义标签和页面

Import and add each of your custom components and pipes to the declarations array in 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 的页面,我需要这个自定义标签,但出现如下错误

EXCEPTION: Error in ./HomePage class HomePage - inline template:18:27 caused by: No component factory found for ShopingcartPage

ORIGINAL EXCEPTION: No component factory found for ShopingcartPage

最佳答案

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

应用程序模块.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

关于angular - ionic2 rc0 中找不到组件工厂错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39897407/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com