1 // Copyright (c) 2016, hackbard. All rights reserved. Use of this source code
2 // is governed by a BSD-style license that can be found in the LICENSE file.
6 import 'package:angular2/core.dart';
7 import 'package:angular2/router.dart';
9 import 'product_category.dart';
10 import 'product_category_service.dart';
12 import 'package:angular2_rbi/directives.dart';
15 selector: 'my-product-categories',
16 templateUrl: 'product_category_component.html',
17 styleUrls: const ['product_category_component.css'],
18 directives: const [MaterialTextfield,MaterialButton],
19 providers: const [ProductCategoryService]
22 class ProductCategoryComponent implements OnInit {
23 List<ProductCategory> product_categories;
24 ProductCategory selected_prod_category;
25 String new_prod_category_name='';
26 final ProductCategoryService _prodcatSrv;
29 ProductCategoryComponent(this._prodcatSrv,this._router);
31 Future<Null> createProductCategory() async {
32 String id = await _prodcatSrv.createProdCategory(
33 new_prod_category_name
35 product_categories.add(new ProductCategory(
36 id,new_prod_category_name,'product_cetegory'
38 new_prod_category_name='';
41 Future<Null> ngOnInit() async {
42 product_categories = await _prodcatSrv.getAll();
45 choose(ProductCategory pt) {
46 selected_prod_category=pt;
50 Future<Null> goto_products(ProductCategory pt) => _router.navigate([
52 {'id': pt.id.toString()}