| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 | import { Component } from '@angular/core';import { NavController, NavParams } from 'ionic-angular';import { Product } from '../../models/product'import { DataProvider } from '../../providers/data-provider'@Component({    selector: 'page-product-details',    providers: [DataProvider],    templateUrl: 'product-details.html'})export class ProductDetailsPage {    product = {        name: "",        type: 0,        salePrice: 0,        ean13: "",        reference: "",        costPrice: 0,        quantity: 0,        salesCount: 0,        active: true    }    constructor(        public navCtrl: NavController,        public params: NavParams,        public data: DataProvider    ) { }    /**     *     */    private isValidForm() {        if (!this.product.name) {            return false;        }        return true;    }    /**     *     */    save(): void {        if (!this.isValidForm()) {            return;        }        this.data.save('product', this.product).then(result => {                this.params.data.push(result.products[0]);            this.navCtrl.pop(this);        });    }}
 |