// Copyright (c) 2016, hackbard. All rights reserved. Use of this source code // is governed by a BSD-style license that can be found in the LICENSE file. import 'dart:async'; import 'package:angular2/core.dart'; import 'package:angular2/router.dart'; import 'product_category.dart'; import 'product_category_service.dart'; import 'package:angular2_rbi/directives.dart'; @Component( selector: 'my-product-categories', templateUrl: 'product_category_component.html', styleUrls: const ['product_category_component.css'], directives: const [MaterialTextfield,MaterialButton], providers: const [ProductCategoryService] ) class ProductCategoryComponent implements OnInit { List product_categories; ProductCategory selected_prod_category; String new_prod_category_name=''; final ProductCategoryService _prodcatSrv; final Router _router; ProductCategoryComponent(this._prodcatSrv,this._router); Future createProductCategory() async { 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=''; } Future ngOnInit() async { product_categories = await _prodcatSrv.getAll(); } choose(ProductCategory pt) { selected_prod_category=pt; goto_products(pt); } Future goto_products(ProductCategory pt) => _router.navigate([ 'Products', {'id': pt.id.toString()} ]); }