<!DOCTYPE html>
<html>

  <head>
    <title>angular2 playground</title>
    <link rel="stylesheet" href="style.css" />
    <script src="https://code.angularjs.org/2.0.0-beta.0/angular2-polyfills.js"></script>
    <script src="https://code.angularjs.org/tools/system.js"></script>
    <script src="https://code.angularjs.org/tools/typescript.js"></script>
    <script src="config.js"></script>
    <script src="https://code.angularjs.org/2.0.0-beta.0/Rx.js"></script>
    <script src="https://code.angularjs.org/2.0.0-beta.0/angular2.min.js"></script>
    <script src="https://code.angularjs.org/2.0.0-beta.0/http.min.js"></script>
    <script>
    System.import('app')
      .catch(console.error.bind(console));
  </script>
  </head>

  <body>
    <my-app>
    loading...
  </my-app>
  </body>

</html>
/* Styles go here */

### Angular2 Starter Plunker - Typescript - Beta 0

A simple plunker demonstrating Angular2 usage:
- Uses SystemJS + TypeScript to compile on the fly
- Includes binding, directives, http, pipes, and DI usage.
System.config({
  //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: './main.ts',
      defaultExtension: 'ts'
    }
  }
});
//main entry point
import {bootstrap} from 'angular2/platform/browser';
import {App} from './app';

bootstrap(App, [])
  .catch(err => console.error(err));
//our root app component
import {Component} from 'angular2/core'

@Component({
  selector: 'my-app',
  providers: [],
  template: `
    <div>
       The min value is 1 and the max value is 5.
       <br>
       <br>
       When setting a number bigger than 5 the value is reset to 5, when smaller than 1 it is reset to 1.
       <br>
       <br>
       The issue here is that only when the value in the input is 1 and i enter 0, the _testValue variable is being reset to 1, however the input still displays 0.
       <br>
       The same happens when i clear the input text -> the _testvalue is reset to 1 correctly but the input is not updated.
        <br>
       <input   type="text"
                [(ngModel)]="testValue"
                onClick="this.select();"
                onkeypress='return event.charCode >= 48 && event.charCode <= 57'>
      
    </div>
  `,
  directives: []
})
export class App {
  private changeValueTimeout;
    
  private _testValue:number = 0;
  private _testValueMax:number = 5;
  
  get testValue() {
    return this._testValue + 1;
  }
  set testValue(value: string) {
    clearTimeout(this.changeValueTimeout);
    var me = this;
    this.changeValueTimeout = setTimeout(() => {
      var numValue:number = Number.parseInt(value);
      if (numValue > me._testValueMax - 1){
        numValue = me._testValueMax;
      } else if (numValue < 1 || isNaN(numValue)){
        numValue = 1;
      }
      me._testValue = numValue - 1;
    }, 1000);
  }
  
  constructor() {
  
  }
}