【发布时间】:2018-06-23 01:45:45
【问题描述】:
离子 v3
我正在我的演示应用中查看通知列表。
列表代码(notifications.html)
<ion-list>
<button ion-item *ngFor="let post of posts" color="{{post.color}}" id="btn_{{post.item}}" (click)="readNotification(post.item)" >
<ion-icon name="{{post.icon}}" item-start></ion-icon>
<h2>{{post.title}}</h2>
<p>{{post.content}}</p>
</button>
</ion-list>
如果点击时为“主要”,我想将点击项目的颜色从“主要”更改为“浅色”。
现在点击函数调用“readNotification”函数并打开一个新视图来显示完整的消息。
默认颜色在 ajax 数据中指定。如果消息未读,则以“原色”显示,如果已读,则以“浅”色显示。
更新
Notifications.ts
export class NotificationsPage {
posts: any;
constructor(
public navCtrl: NavController,
public http: Http,
private localNotifications:
LocalNotifications
) {
this.http.get('xxx?oper=getNotificationsJSON')
.map(res => res.json())
.subscribe(data => {
this.posts = data.results;
},
err => {
console.log("oops!");
});
}
readNotification(item: string) {
this.navCtrl.push(ReadNotificationPage, {
id: item
});
}
}
【问题讨论】:
-
究竟是什么不起作用?请分享您组件的重要部分
-
我只是不知道如何添加这个“更改颜色”功能。
标签: angular ionic-framework ionic3