comparison src/app/simple-form/simple-form.component.ts @ 3:b4a1e0a67389

Playing around with material2
author Lucas Thompson <dev@lucas.im>
date Wed, 26 Oct 2016 11:42:58 +0100
parents 44c99e3cb108
children
comparison
equal deleted inserted replaced
2:628693abcbed 3:b4a1e0a67389
1 import { 1 import {
2 Component, OnInit, Input, Output, EventEmitter, 2 Component, OnInit, Input, Output, EventEmitter,
3 ViewEncapsulation 3 ViewEncapsulation, ViewChild, ElementRef
4 } from '@angular/core'; 4 } from '@angular/core';
5 5
6 @Component({ 6 @Component({
7 encapsulation: ViewEncapsulation.Emulated, 7 encapsulation: ViewEncapsulation.Emulated,
8 selector: 'app-simple-form', 8 selector: 'app-simple-form',
12 [ngClass]="{mousedown: isMousedown}" 12 [ngClass]="{mousedown: isMousedown}"
13 (mousedown)="isMousedown = true" 13 (mousedown)="isMousedown = true"
14 (mouseup)="isMousedown = false" 14 (mouseup)="isMousedown = false"
15 (mouseleave)="isMousedown = false" 15 (mouseleave)="isMousedown = false"
16 /> 16 />
17 <pre #testPre>Hi</pre>
18 <pre>{{testHi}}</pre>
17 <button (click)="update.emit({text:message})">Click me!</button> 19 <button (click)="update.emit({text:message})">Click me!</button>
18 `, 20
19 styles: [` 21 `,
20 :host { 22 styleUrls: ['./simple-form.component.css']
21 display: flex;
22 flex-direction: column;
23 }
24
25 .mousedown {
26 border: 2px solid green;
27 }
28
29 input:focus {
30 font-weight: bold;
31 outline: none;
32 }
33
34 button {
35 border: none;
36 }
37 `]
38 }) 23 })
39 export class SimpleFormComponent implements OnInit { 24 export class SimpleFormComponent implements OnInit {
25
26 @ViewChild('testPre') testPre: ElementRef;
27 testHi = 'Hi';
40 28
41 isMousedown; 29 isMousedown;
42 30
43 @Input() message; 31 @Input() message;
44 32
47 constructor() { 35 constructor() {
48 // setInterval(() => this.message = Math.random().toString(), 1000); 36 // setInterval(() => this.message = Math.random().toString(), 1000);
49 } 37 }
50 38
51 ngOnInit() { 39 ngOnInit() {
40 this.testPre.nativeElement.innerHTML = Math.random().toString();
52 } 41 }
53 42
54 } 43 }