Skip to content

Instantly share code, notes, and snippets.

View isummation's full-sized avatar

iSummation INC isummation

View GitHub Profile
@isummation
isummation / code1.js
Last active September 28, 2017 11:56
setTimeout(function(){
console.log("callled later");
}, 1000);
console.log("Called first");
const _config = require('../config');
const sql = require('mssql');
setTimeout(function(){
console.log("callled later");
}, 1000);
<div class="container">
<div class="col-md-6">
<h3 class="title">Dynamic Form Component</h3>
<dynamic-form [formConfig]="formConfig" (formSubmit)="onSubmit($event)"></dynamic-form>
</div>
</div>
import { DynamicControlConfig } from './dynamic-form/dynamic-control.config';
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
formConfig: DynamicControlConfig[];
// app.module.ts
import { DynamicFormModule } from './dynamic-form';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent,
],
imports: [
// dynamic-form.component.ts
import { DynamicFormControlComponent } from './dynamic-form-control/dynamic-form-control.component';
import { DynamicControlConfig } from './dynamic-control.config';
import { FormGroup, FormControl } from '@angular/forms';
import { Component, OnInit, Input, EventEmitter, Output, ViewChild } from '@angular/core';
import { ViewContainerRef, ComponentFactoryResolver, OnChanges } from '@angular/core';
@Component({
// tslint:disable-next-line:component-selector
selector: 'dynamic-form',
template: `
// dynamic-form-control.component.ts
import { DynamicControlConfig } from './../dynamic-control.config';
import { FormGroup } from '@angular/forms';
import { Component } from '@angular/core';
@Component({
// tslint:disable-next-line:component-selector
selector: 'dynamic-form-control',
template: `
<div [formGroup]="formGroup" class="form-group">
<label>{{controlConfig.label}}</label>
// dynamic-form.module.ts
import { DynamicFormComponent } from './dynamic-form.component';
import { ReactiveFormsModule, FormsModule } from '@angular/forms';
import { DynamicFormControlComponent } from './dynamic-form-control/dynamic-form-control.component';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
@NgModule({
imports: [
CommonModule,
// dynamic-control.config.ts
export interface DynamicControlConfig {
type: string;
name: string;
label: string;
placeholder: string;
}