Skip to content

Instantly share code, notes, and snippets.

View jhades's full-sized avatar

Vasco Cavalheiro jhades

View GitHub Profile
@jhades
jhades / 01.ts
Created May 22, 2016 17:58
Angular 1 Vs Angular 2 - An In-Depth Comparison
element.addEventListener('keyup', function () {
console.log('Key pressed.');
});
@jhades
jhades / 01.html
Last active August 24, 2016 15:16
Introduction to Angular 2 - The fundamentals of Components
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="audi">Audi</option>
</select>
@jhades
jhades / 01.html
Last active December 18, 2020 10:12
Introduction to Angular Forms - Template Driven and Reactive Forms - https://blog.angular-university.io/introduction-to-angular-2-forms-template-driven-vs-model-driven/
<section class="sample-app-content">
<h1>Template-driven Form Example (with bi-directional data binding):</h1>
<form #myForm="ngForm" (ngSubmit)="onSubmitTemplateBased()">
<p>
<label>First Name:</label>
<input type="text"
[(ngModel)]="user.firstName" required>
</p>
<p>
<label>Password:</label>
@jhades
jhades / 01.js
Created May 22, 2016 20:22
Introduction to the Jspm package manager and the SystemJs module loader
var $ = require('jquery');
$('body').append("I've imported jQuery!");
@jhades
jhades / 01.ts
Last active May 23, 2016 07:32
Angular 2 Application Architecture - Building Flux Apps with Redux and Immutable.js
{
todos:[
{
"id":1,
"description":"TODO 1",
"completed":false
},
{
"id":2,
"description":"TODO 2",
@jhades
jhades / 01.ts
Last active May 26, 2016 22:18
How to create an Angular 2 component library, and how to consume it using SystemJs or Webpack
import {HelloWorld}
from 'angular-library-example/components';
@jhades
jhades / 01.ts
Last active October 10, 2024 00:03
Functional Reactive Programming for Angular Developers - RxJs and Observables
const obs = interval(1000).pipe(take(5));
@jhades
jhades / 01.ts
Last active December 17, 2020 13:25
export class AddTodoAction {
constructor(public newTodo: Todo) {
}
}
export class ToggleTodoAction {
constructor(public todo: Todo) {
}
@jhades
jhades / 01.ts
Last active December 18, 2020 11:50
How does Angular 2 Change Detection Really Work ?
// this is the new version of addEventListener
function addEventListener(eventName, callback) {
// call the real addEventListener
callRealAddEventListener(eventName, function() {
// first call the original callback
callback(...);
// and then run Angular-specific functionality
var changed = angular.runChangeDetection();
if (changed) {
angular.reRenderUIPart();
@jhades
jhades / 01.ts
Created May 23, 2016 09:15
Angular 2 coming to Java, .NET and PHP: the first multi-language full stack platform?
import {ng2engine} from 'angular2-universal';
let app = express();
// config view engine
app.engine('.html', ng2engine);
app.set('views', __dirname);
app.set('view engine', 'html');
// config the root route