@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
46 lines (41 loc) • 1.61 kB
text/typescript
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';
export class <%-SchemaName%>DetailFieldComponent extends <%-SchemaName%>Component
implements OnInit {
showFields: 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() {
if (!this.showFieldsStr) {
console.error("A field has to be given to show it.");
return;
}
let showFields = this.showFieldsStr.match(/\S+/g);
this.showFields = showFields? showFields : [];
if (this.detailObj) {
this.onDetailReturned(this.detailObj, '');
} else {
if (!this.id) this.id = this.id;
if (this.id) this.populateDetail(this.id);
else {
console.error("No id provided to show info");
return;
}
}
}
}