Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // app.module.ts
- import { BrowserModule } from '@angular/platform-browser';
- import { NgModule } from '@angular/core';
- import { AppComponent } from './app.component';
- import { UserComponent } from './user.component';
- import { FormsModule } from '@angular/forms';
- @NgModule({
- declarations: [
- UserComponent
- ],
- imports: [
- BrowserModule,
- FormsModule
- ],
- providers: [],
- bootstrap: [
- UserComponent
- ]
- })
- export class AppModule { }
- // user.component.ts
- import { Component } from '@angular/core';
- export class User {
- id: number;
- email: string;
- password: string;
- }
- @Component({
- selector: 'user',
- templateUrl: './user.component.html',
- styleUrls: ['./user.component.css']
- })
- export class UserComponent {
- user: User = {
- id: 1,
- email: 'localhost@test.local',
- password: 'password'
- }
- }
- // user.component.html
- <div>
- <div>{{ user.email }}</div>
- <div>
- <label>name: </label>
- <input [(ngModel)]="user.email" placeholder="name">
- </div>
- </div>
- // index.html
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>MyApp</title>
- <base href="/">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="icon" type="image/x-icon" href="favicon.ico">
- </head>
- <body>
- <user></user>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement