Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
angular 2 basic counter

angular 2 basic counter

Basic counter in Angular 2.

//use typescript for compilation
transpiler: 'typescript',
//typescript compiler options
typescriptOptions: {
emitDecoratorMetadata: true
//map tells the System loader where to look for things
map: {
app: './src'
//packages defines our app package
packages: {
app: {
main: './counter.ts',
defaultExtension: 'ts'
<!DOCTYPE html>
<title>angular 2 basic counter</title>
<link rel="stylesheet" href="style.css" />
<script src=""></script>
<script src=""></script>
<script src=""></script>
<script src="config.js"></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>
import {Component} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';
selector: 'app',
template: `
<button (click)="increment()">Increment</button>
<button (click)="decrement()">Decrement</button>
export class App {
public counter : number = 0;
this.counter += 1;
this.counter -= 1;
bootstrap(App, []);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.