Skip to content

Instantly share code, notes, and snippets.

@vades
vades / Angular-Lodash.md
Last active May 21, 2019 10:20
Using Lodash in Angular applications

Using Lodash in Angular applications

Lodash is a JavaScript library that helps programmers deal with all types of object.

Tested on

  • Angular: 7.0.3
  • Node: 8.10.0
  • Typescript: 3.1.6

Do npm install

@vades
vades / Angular-Architecture.md
Last active May 22, 2019 13:41
How to structure Angular project

How to structure Angular project

A good guideline to follow is to split Angular application into at least three modules:

  1. Core.
  2. Features.
  3. Shared.

Core

All services which have to have one instance per application should be implemented here.

Features

@vades
vades / angular-root-path.md
Last active May 22, 2019 12:49
Use root paths for module imports in Angular

Use root paths for module imports

Add your application source via paths in tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "src",
    ...
 "paths": {
@vades
vades / angular-chart-js.md
Last active May 21, 2019 06:07
Angular and Chart.js with ng2-charts

Angular and Chart.js with ng2-charts

Chart.js is a JavaScript library which makes it easy to create animated and responsive charts. If you want to combine Chart.js with Angular you can use ng2-charts.

Tested on

  • Angular: 7.0.3
  • Node: 8.10.0
  • Typescript: 3.1.6

Install Chart.js using npm

@vades
vades / angular-cli-no-spec.md
Last active May 21, 2019 06:08
Generating things without .spec.ts in Angular

Generating things without .spec.ts in Angular

Disable generation using CLI by adding --no-spec

ng generate component component-name --no-spec

Permanently disable in angular.json

@vades
vades / laravel-json-to-collection.md
Last active October 24, 2024 13:02
Convert JSON data to Eloquent collection in Laravel application

Convert JSON data to Eloquent collection in Laravel application

$collection = collect(json_decode($response));
$items = $collection->where('id', 25);
@vades
vades / font_awesome-icon-sizes.md
Last active May 21, 2019 06:11
Font Awsome: sizing icons

Sizing Font Awesome icons

Basic sizing

<i class="fas fa-igloo fa-xs"></i>
<i class="fas fa-igloo fa-sm"></i>
<i class="fas fa-igloo fa-lg"></i>
<i class="fas fa-igloo fa-2x"></i>
<i class="fas fa-igloo fa-3x"></i>
<i class="fas fa-igloo fa-5x"></i>
@vades
vades / angular-timeout.md
Last active May 21, 2019 06:13
Using timeout in Angular App

Using timeout in Angular App

You have to use ArrowFunction ()=>

export class YourComponent implements OnInit {

  ngOnInit() {
   setTimeout(()=> {
 console.log('Running timeout');
@vades
vades / laravel-logging.md
Last active May 21, 2019 06:14
Laravel logging

Laravel logging

Laravel provides logging services that allow you to log errors, messages, events and uses Monolog, a powerful popular PHP logging library for all its logging needs.

Configuration

config/logging.php 

Log levels

  • emergency,
  • alert,
@vades
vades / angular-constructor-onInit-difference.md
Last active May 21, 2019 06:16
Difference between Constructor and ngOnInit in Angular app

Difference between Constructor and ngOnInit

Constructor

is a default method runs by deafult when component is being constructed.

ngOnInit

is component's life cycle hook which runs first after constructor when component is being initialized.

Source

Difference between Constructor and ngOnInit