I am new to Angular 2 and TypeScript and I\'m trying to follow best practices.
Instead of using a simple JavaScript model ({ }), I\'m attempting to create a TypeScri
my code is
import { Component } from '@angular/core';
class model {
username : string;
password : string;
}
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
username : string;
password : string;
usermodel = new model();
login(){
if(this.usermodel.username == "admin"){
alert("hi");
}else{
alert("bye");
this.usermodel.username = "";
}
}
}
and the html goes like this :
Usernmae :
Password :