【发布时间】:2021-04-17 02:57:42
【问题描述】:
我仍然在学习角度,离子和我很困惑我的错在哪里,我一直在寻找另一个问题,但我仍然不明白,你们能帮我吗?也许你有一些代码可以清楚地解释它?
这是我的 product-list.component.ts
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
@Component({
selector: 'page-prod-list-view',
templateUrl: 'product-list.component.html',
styleUrls: ['product-list.component.css']
})
export class ProductListComponent {
products = [
{
name: 'Phone XL',
price: 799,
description: 'A large phone with one of the best screens'
},
{
name: 'Phone Mini',
price: 699,
description: 'A great phone with one of the best cameras'
},
{
name: 'Phone Standard',
price: 299,
description: ''
}
];
share() {
window.alert('The product has been shared!');
}
view() {
window.alert('The product has been viewed!');
}
}
这是我的 product-list.module.ts
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { ProductListComponent } from './product-list.component';
@NgModule({
declarations: [
ProductListComponent
],
imports: [
IonicPageModule.forChild(ProductListComponent),
],
exports: [
ProductListComponent
]
})
export class ProductListModule { }
这是我的html
<h2>Products</h2>
<div *ngFor="let product of products">
<h3>
<a [title]="product.name + ' details'">
{{ product.name }}
</a>
</h3>
<p *ngIf="product.description">
Description: {{ product.description }}
</p>
<button (click)="share()">
Share
</button>
<button (click)="view()">
View
</button>
</div>
【问题讨论】:
-
构造函数和ngOnInit在哪里?
-
您必须描述您的错误。什么时候发生?什么除外? ...
标签: javascript angular ionic-framework