export class User {
constructor( public username: string, public password: string ) { let user = new User('aaa', 'a'); console.log('My username is ' + user.username); }}import { Component, OnInit } from '@angular/core';import { User } from '../user';
@Component({ selector: 'app-login-form', templateUrl: './login-form.component.html', styleUrls: ['./login-form.component.css']})export class LoginFormComponent {
model = new User('Tester1', '12345');
submitted = false;
onSubmit() { this.submitted = true; }
// TODO: Remove this when we're done get diagnostic() { return JSON.stringify(this.model); }
}
import { BrowserModule } from '@angular/platform-browser';import { NgModule } from '@angular/core';import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';import { LoginFormComponent } from './login-form/login-form.component';
@NgModule({ declarations: [ AppComponent, LoginFormComponent ], imports: [ BrowserModule, FormsModule ], providers: [], bootstrap: [AppComponent]})export class AppModule { }
<app-login-form></app-login-form>