UNPKG

@hicoder/angular-cli

Version:

Angular UI componenets and service generator. It works with the mean-rest-express package to generate the end to end web application. The input to this generator is the Mongoose schema defined for the express application. mean-rest-express exposes the Res

48 lines (40 loc) 1.63 kB
import { Component, OnInit, Input } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { Injector } from '@angular/core'; import { <%-SchemaName%>Component, ViewType } from '../<%-schemaName%>.component'; import { <%-SchemaName%>Service } from '../<%-schemaName%>.service'; @Component({ <%- include(`/widgets/detail/component.template.custom.ts`)%> }) export class <%-SchemaName%><%-ComponentClassName%>Component extends <%-SchemaName%>Component implements OnInit { @Input() public override id:string = ''; public override associationField: string= ''; public associationSchema: string = ''; constructor( public override <%-schemaName%>Service: <%-SchemaName%>Service, public override injector: Injector, public override route: ActivatedRoute, ) { super(<%-schemaName%>Service, injector, route); this.view = ViewType.DETAIL; <% let theView = detailView; let isEditView = false;%><%- include('/schema-construct.component.ts', {theView: detailView, isEditView: false}) %> } override ngOnInit() { // urls in <schema>/association/:id/<assoSchema>/<assoField> format let urls = this.route.snapshot.url.join().split(','); this.associationSchema = urls[urls.length-2]; this.associationField = urls[urls.length-1]; this.detail = {}; let id = this.route.snapshot.paramMap.get('id'); if (!this.id) this.id = id? id : ''; if (this.id) { this.populateDetail(this.id); } else { console.error("Routing error for association detail view... no id..."); } } ngAfterViewInit() { // Do nothing. } }