离子2/3;当Onclick
问题描述:
改变图像src标签我有离子页面有100%宽度和100%高度的图像,我想改变图像来源,当我点击它。离子2/3;当Onclick
这是HTML源:
这的TS来源:
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import {ParrotListPage } from '../parrot-list/parrot-list';
/**
* Generated class for the MapPage page.
*
* See https://ionicframework.com/docs/components/#navigation for more info on
* Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-map',
templateUrl: 'map.html',
})
export class MapPage {
images: String[] = Array("img//map.jpg", "img/map1.jpg");
constructor(public navCtrl: NavController, public navParams: NavParams) {
}
changeView(){
}
ionViewDidLoad() {
console.log('ionViewDidLoad MapPage');
}
ListParrots(){
this.navCtrl.push(ParrotListPage);
}
}
能有人帮助,请完成所有的功能?谢谢 !
答
更改模板:
<ion-img class="map" [src]="picToView" (click)="changeView()"></ion-img>
,并宣布在类的变量:
picToView:string="img/map.jpg"; // always instatiate with a valid value
而且changeView:
changeView(){
this.picToView=.....
}
问候
汤姆