-
-
Save galek/dbdf988dfd1c55a63ad613b720973a5b to your computer and use it in GitHub Desktop.
Category
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Login page logic | |
* last edit 27.04.19 20:31 | |
* Author: NickGalko [email protected] | |
* | |
* Changes: | |
* 1) Fix for logic, show error messeage received from server | |
*/ | |
import { Component } from '@angular/core'; | |
import { NavController, Platform, NavParams } from 'ionic-angular'; | |
import { API } from '../../code/apiprovider'; | |
import { FormBuilder } from "@angular/forms"; | |
import { GlobalUserInfo } from '../../code/globaluserinfo'; | |
import { SettingsContainer } from '../../code/settings'; | |
import { PagesHelper } from '../../code/pagesHelper'; | |
@Component({ | |
selector: 'page-category-module', | |
templateUrl: 'Category.html' | |
}) | |
export class CategoryPage { | |
loading: boolean = true; | |
products: any; | |
subCategories: any; | |
heading_title: string = ""; | |
slides: any = []; | |
constructor(public formBuilder: FormBuilder, | |
public navCtrl: NavController, | |
public navParams: NavParams, | |
public api: API, | |
public user: GlobalUserInfo, | |
public settings: SettingsContainer, | |
public pl: Platform) { | |
this.slides.push("test"); | |
this.slides.push("test"); | |
this.slides.push("test"); | |
this.slides.push("test"); | |
this.slides.push("test"); | |
this.slides.push("test"); | |
this.slides.push("test"); | |
this.slides.push("test"); | |
this.slides.push("test"); | |
this.slides.push("test"); | |
this.slides.push("test"); | |
this.slides.push("test"); | |
this.slides.push("test"); | |
this.slides.push("test"); | |
this.slides.push("test"); | |
this.slides.push("test"); | |
} | |
private _getDataFromServer(_id: string) { | |
this.loading = true; | |
if (!this.api) { | |
console.error("Not exist api"); | |
return; | |
} | |
this.api.getItem("product/category&path=" + _id).subscribe( | |
value => { | |
this.products = value.products; | |
this.subCategories = value.categories; | |
this.heading_title = value.heading_title; | |
this.loading = false; | |
}, | |
error => { | |
console.error(error); | |
this.loading = false; | |
}); | |
// this.api.getItem("product/category&path=" + _id).toPromise().then(value => { | |
// this.products = value.products; | |
// this.subCategories = value.categories; | |
// this.heading_title = value.heading_title; | |
// this.loading = false; | |
// }).catch(error => { | |
// console.error(error); | |
// this.loading = false; | |
// }); | |
} | |
// ionViewDidLoad() { | |
ngOnInit() { | |
console.error("6"); | |
var id = this.navParams.get('id'); | |
if (id == undefined) { | |
console.error("Invalid product id"); | |
return; | |
} | |
this._getDataFromServer(id); | |
} | |
getProduct(product_id: number) { | |
PagesHelper.goToProductPage(this.navCtrl, false, { id: product_id }); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment