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

63 lines (53 loc) 1.76 kB
import { Component, OnInit, Input, OnChanges, ViewChild } from '@angular/core'; import { NgbCarousel } from '@ng-bootstrap/ng-bootstrap'; import { <%-SchemaName%>ListViewComponent } from './<%-schemaName%>-list-view.component'; @Component({ <%- include(`/widgets/list-view/component.template.custom.ts`)%> }) export class <%-SchemaName%><%-ComponentClassName%>Component extends <%-SchemaName%>ListViewComponent implements OnInit, OnChanges { public errMsg: string = ''; public fields: any = {<% for (let field of briefView) {%><% if (field.slideTitle) {%> title: '<%-field.fieldName%>',<% }%><% if (field.slideSubTitle) {%> subtitle: '<%-field.fieldName%>',<% }%><% if (field.slideDescription) {%> description: '<%-field.fieldName%>',<% }%><% if (field.slidePicture) {%> picture: '<%-field.fieldName%>',<% }%><% if (field.slideLinkDisplay) {%> linkDisplay: '<%-field.fieldName%>',<% }%><% if (field.slideLinkURL) {%> linkURL: '<%-field.fieldName%>',<% }%><% }%> }; @ViewChild('carousel', {static: true}) carousel: NgbCarousel = {} as NgbCarousel; constructor() { super(); } override ngOnInit() { super.ngOnInit(); this.setFields(); } ngOnChanges() { this.setFields(); if (this.carousel) { this.carousel.cycle(); } } setFields() { if ( Array.isArray(this.inputData) ) { this.fields.title = this.inputData[0] || this.fields.title; this.fields.subtitle = this.inputData[1] || this.fields.subtitle; this.fields.description = this.inputData[2] || this.fields.description; this.fields.picture = this.inputData[3] || this.fields.picture; this.fields.link = this.inputData[4] || this.fields.link; } } }