Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component } from '@angular/core';
- import { FormBuilder, Validators} from '@angular/forms';
- import { NavController, NavParams } from 'ionic-angular';
- import { MyApp } from '../../app/app.component';
- import { HttpService } from '../../providers/http-service';
- /**
- * Generated class for the EditShowcaseSalesPage page.
- *
- * See https://ionicframework.com/docs/components/#navigation for more info on
- * Ionic pages and navigation.
- */
- @Component({
- selector: 'page-edit-showcase-sales',
- templateUrl: 'edit-showcase-sales.html',
- })
- export class EditShowcaseSalesPage {
- public static TAG = "Edit Showcase";
- public data;
- public showcaseForm;
- public idShowcase;
- public isDataLoad: boolean = false;
- public dataShowcaseReady: boolean = false;
- public dataShowcase;
- constructor(public navCtrl: NavController, public navParams: NavParams, public http: HttpService, public formBuilder: FormBuilder)
- {
- try{
- this.data = {};
- this.showcaseForm = this.formBuilder.group(
- {
- name : ['', Validators.required]
- });
- }catch(error){
- MyApp.consoleLog("some error happen", error);
- }
- }
- ionViewDidLoad(id) {
- console.log('ionViewDidLoad EditShowcaseSalesPage');
- this.idShowcase = this.navParams.get('id');
- MyApp.consoleLog("Data = ", this.idShowcase);
- }
- ionViewDidEnter(){
- try{
- this.loadShowcase();
- //MyApp.consoleLog(EditShowcaseSalesPage.TAG, "load...", this.loadShowcase());
- }catch(error){
- MyApp.consoleLog("some error happen", error);
- }
- }
- editShowcase(){
- let link = "http://localhost/phpscring/shop_showcase_sales/edit_showcase";
- let editShowcase;
- editShowcase = {};
- editShowcase.id = this.idShowcase;
- editShowcase.name = this.showcaseForm.value.name;
- let postParams = {
- "link": link,
- "data": editShowcase
- }
- MyApp.consoleLog(EditShowcaseSalesPage.TAG, "postParams ", postParams);
- this.http.postService(postParams).then((data)=>{
- this.data.response = data;
- MyApp.consoleLog(EditShowcaseSalesPage.TAG, " data response ", data);
- MyApp.consoleLog(EditShowcaseSalesPage.TAG, "response", editShowcase);
- this.navCtrl.pop()
- if (this.isDataLoad= true) {
- this.dataShowcaseReady = false;
- this.loadShowcase(editShowcase);
- }
- else{
- this.isDataLoad = true;
- this.dataShowcaseReady = false;
- this.loadShowcase(editShowcase);
- }
- }, error => {
- MyApp.consoleError(editShowcase.TAG, error);
- });
- MyApp.consoleLog("ShopShowcase", "Update Showcase");
- }
- back(){
- this.navCtrl.pop();
- }
- loadShowcase(editShowcase){
- this.dataShowcase = [];
- if(editShowcase.data.length != 0 ){
- for(let i = 0; i < editShowcase.data.length; i++){
- this.dataShowcase[i] = {
- id: response.data[i].id,
- name: response.data[i].name,
- }
- }
- }
- MyApp.consoleLog(EditShowcaseSalesPage.TAG, "dataShowcase .......data", this.dataShowcase);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement