Skip to content

Instantly share code, notes, and snippets.

View camilogiraldo's full-sized avatar

Camilo Giraldo camilogiraldo

View GitHub Profile
@camilogiraldo
camilogiraldo / Creating a new Angular application
Last active January 18, 2018 01:53
Creating a new Angular application
/** This assumes you have @angular/cli installed **/
/** creating our Angular application **/
ng new fancy-app --routing
@camilogiraldo
camilogiraldo / Creating our components
Created January 18, 2018 01:43
Creating our components
/** Creating our HomeComponent **/
ng generate component HomeComponent --spec=false
/** Creating our BigFeatureComponent **//
ng generate component BigFeatureComponent --spec=false
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponentComponent } from './home-component/home-component.component';
import { BigFeatureComponentComponent } from './big-feature-component/big-feature-component.component';
// New code
const routes: Routes = [
{ path: '', pathMatch: 'full', redirectTo: 'home'},
{ path: 'home', component: HomeComponentComponent},
{ path: 'bigComponent', component: BigFeatureComponentComponent}
<a routerLink='/home'>Home</a>
<a routerLink='/bigComponent'>Feature</a>
<h1>
Home Component
</h1>
<p>
Home component will be the first screen when the user visits our page.
</p>
<a routerLink='/home'>Home</a>
<a routerLink='/bigComponent'>Feature</a>
<h1>
Big Feature here.
</h1>
<p>
Here is where the big feature of our fancy app will reside.
</p>
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { HomeComponentComponent } from './home-component/home-component.component';
import { BigFeatureComponentComponent } from './big-feature-component/big-feature-component.component';
@NgModule({
declarations: [
@camilogiraldo
camilogiraldo / Generate new module
Created January 24, 2018 02:20
Generate new module
//Generate a new module, the one that will be lazy loaded
ng generate module big-module --routing
@camilogiraldo
camilogiraldo / app-routing.module.ts
Created January 24, 2018 02:37
Updated app routing
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponentComponent } from './home-component/home-component.component';
const routes: Routes = [
{ path: '', pathMatch: 'full', redirectTo: 'home'},
{ path: 'home', component: HomeComponentComponent},
{ path: 'bigComponent', loadChildren: './big-module/big-module.module#BigModuleModule'} // Code modified
];
@camilogiraldo
camilogiraldo / big-module-routing.module.ts
Created January 24, 2018 02:43
Routing for our lazy loaded route
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { BigFeatureComponentComponent } from './big-feature-component/big-feature-component.component';
const routes: Routes = [
{ path: '', component: BigFeatureComponentComponent}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
@camilogiraldo
camilogiraldo / form-data.ts
Last active February 28, 2019 01:06
app/shared/interface/form-data.ts
// create form-data.ts under app/shared/interface/form-data.ts
export interface FormData {
controlName: string;
controlType: string;
valueType?: string;
currentValue?: string;
placeholder?: string;
options?: Array<{
optionName: string;