class ProductCategoryComponent implements OnInit {
List<ProductCategory> product_categories;
ProductCategory selected_prod_category;
- String new_prod_category_name;
- String new_prod_category_id;
+ String new_prod_category_name='';
final ProductCategoryService _prodcatSrv;
final Router _router;
- var docreate=false;
ProductCategoryComponent(this._prodcatSrv,this._router);
- Future<Null> getProductCategories() async {
- product_categories = await _prodcatSrv.getAll();
- }
-
Future<Null> createProductCategory() async {
- await _prodcatSrv.createProdCategory(
- new_prod_category_name,
- new_prod_category_id
+ String id = await _prodcatSrv.createProdCategory(
+ new_prod_category_name
);
+ product_categories.add(new ProductCategory(
+ id,new_prod_category_name,'product_cetegory'
+ ));
+ new_prod_category_name='';
}
- void ngOnInit() {
- getProductCategories();
- }
-
- void checkInput() {
- if(new_prod_category_name=='' || new_prod_category_id=='') {
- docreate=false;
- }
- else {
- docreate=true;
- for(var cat in product_categories) {
- if(cat.id==new_prod_category_id) {
- docreate=false;
- break;
- }
- }
- }
+ Future<Null> ngOnInit() async {
+ product_categories = await _prodcatSrv.getAll();
}
choose(ProductCategory pt) {