Effective Programming

Git – How to Undo the Last Commit

Heads up! This example is based on a git repository which has at least 2 commits already. Only start to git reset from the second commit & on-wards. Committed wrong files and haven’t pushed the commit to remote server, if you wish to undo it, it can be done. git commit -m "Committed wrong files"... » read more

Angular – TypeScript Constructor versus Angular ngOnInit

TypeScript constructor and Angular ngOnInit look pretty much the same, but they have differences. 1. Injecting and Consuming Service Use constructor for injecting dependencies into the class. This is because of the execution of constructor always comes before ngOnInit. app/user/user.service.ts import { Injectable } from '@angular/core'; @Injectable() export class UserService{ getUsers(): Array<any>{ return [{ name... » read more

Angular – Components Introduction

In Angular, Component is foundation of Angular app. Thus, we should understand what Component is first. Angular Component code structure is made up of three elements. The code example below breaks each element into a single section. //First section import { Component } from '@angular/core'; @Component({ //Second Section selector: 'main-component', template: `{{name}}` }) export class... » read more

NPM – How to install Node.js and NPM

To install NPM, you have to intall Node.js first into your computer. To install Node.js, go to this website and download by following instructions stipulated in the Node.js official website. To check if you have Node.js installed, run this command in your terminal: node -v To confirm that you have npm installed you can run... » read more

Angular – Setup in your local computer with QuickStart seed

Prerequisites: Git is required for Clone method Node.js and NPM are required. Use either clone or download. Clone Run in either bash or command prompt. With this command, it downloads Angular QuickStart into a folder e.g. quickstart. git clone quickstart   Download Download the QuickStart seed and unzip it into your project folder e.g. quickstart. After Angular... » read more

Angular – Setup in your local computer with CLI

Prerequisites: Node.js and npm, node 6.9.x or above & npm 3.x.x or above Angular CLI (Command-Line Interface) provides the simplest way to setup an Angular app into local computer. 1. Install Angular CLI. Use npm command. Run this in either bash or command prompt. npm install -g @angular/cli 2. Verify if Angular CLI is installed successfully by... » read more