0
我試圖在離子2警告框中顯示選定的索引值。但我沒有得到正確的方式如何顯示在離子的提示。如何使用離子2框架在警報框中顯示選定的索引值
這是home.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import {AlertController} from 'ionic-angular';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
companies: Array< {name: string, code: number}>
constructor(public navCtrl: NavController, public alertController:
AlertController) {
this.companies = [
{name: 'Microsoft', code: 1},
{name: 'Apple', code: 2},
{name: 'Google', code: 3},
{name: 'Oracle', code: 4},
{name: 'IBM', code: 5},
];
}
delete(no) {
let alert = this.alertController.create({
title: "Example",
subTitle: "Example SubTitle" + {{no}};
buttons: ["OK"]
});
alert.present();
(this.companies).splice(no, 1);
}
}
在上面的刪除功能delete(no)
我傳遞no
作爲參數刪除功能,我需要在警告對話框顯示相同的值。
爲什麼你在刪除方法周圍'no'大括號? – CuriousMind
沒有任何價值,我必須在警示框中顯示 – user993164
然後只需連接它,不需要放大括號。 – CuriousMind