Skip to content

Instantly share code, notes, and snippets.

View killerchip's full-sized avatar

Costas Ioannou killerchip

  • Morrow Digital
  • Larissa, Greece
View GitHub Profile
@killerchip
killerchip / angular-guide-bootstrap-setup.md
Created January 1, 2018 06:47
Angular guide: Setup Bootstrap with Angular project
@killerchip
killerchip / angular-cheat-reactive-forms.md
Created January 1, 2018 06:45
Angular cheatsheet: Reactive Forms

Reactive Forms

A quick reference guide on how to setup.

How to setup

import ReactiveFormsModule

import { ReactiveFormsModule } from '@angular/forms';
@NgModule ({
@killerchip
killerchip / angular-tip-httpclient-results-map.md
Created January 1, 2018 06:43
Angular Tip: Map HttpClient results to your model class

Map HttpClient results to model

When you use remote APIs, you might not have the model of the reponse JSON object, or it might not match to your app model. Don't be afraid to use map operator to transform the results.

Example

If you query https://jsonplaceholder.typicode.com/posts/ you will receive an array of articles. An article has the following format:

@killerchip
killerchip / angular-cheat-template-driven-forms.md
Created January 1, 2018 06:40
Angular cheatsheet: Template driven forms

Template Driven Forms

How to setup

import FormsModule

import { FormsModule } from '@angular/forms';
  
@NgModule ({
 ...
@killerchip
killerchip / typescript-cheat-enums.md
Last active April 29, 2018 04:01
Typescript cheatsheet: Enums

Enums

Defining an Enum

// Simple Enum
enum Role {Employee, Manager, Admin}

// Custom start value
enum RolesCustomStart {Employee = 3, Manager, Admin}
@killerchip
killerchip / angular-cheat-directives-ngnonbindable.md
Created January 1, 2018 06:34
Angular cheatsheet: Directives / NgNonBindable

NgNonBindable

Helps you 'disable' bidding in HTML so you can use the {{ content }} double brackets as is.

  <div ngNonBindable>
    {{ this should be rendered as is and not interpolated. }}
  </div>
@killerchip
killerchip / angular-cheat-directives-ngclass.md
Created January 1, 2018 06:32
Angular cheatsheet: Directives / NgClass

NgClass

  <div [ngClass]="{bordered: true, 'white-background': false}"></div>
  <div [ngClass]="['class1','class2','class3']"></div>

tip: You can use a classes object in your code and bind it to template

component code

@killerchip
killerchip / angular-cheat-directives-ngstyle.md
Created January 1, 2018 06:30
Angular cheatsheet: Directives/NgStyle

NgStyle

Single property

  <div [style.background-color]="'black'"></div>

Multiple properties at once

 
@killerchip
killerchip / angular-cheatsheet-directives-ngswitch.md
Created January 1, 2018 06:28
Angular cheatsheet: Directives / NgSwitch

NgSwitch

ngSwitchDefault is optional.

<div [ngSwitch] = "position">
  <div *ngSwitchCase = "1">You are 1st!</div>
  <div *ngSwitchCase = "2">You are 2nd!</div>
  <div *ngSwitchCase = "3">You are 3rd!</div>
 You are not worth mentioning!
@killerchip
killerchip / angular-cheat-directives-ngfor.md
Last active January 1, 2018 06:27
Angular cheatsheet: Directives / NgFor

NgFor

In this example we also demonstrate how to print an array of strings with a comma separator in between them.

in component

public values = ['one','two','three'];

in HTML template