Created
May 22, 2020 04:26
-
-
Save Sourabhhsethii/9421f5704366e7ba81671ae2faaa93d2 to your computer and use it in GitHub Desktop.
SampleFormComponentComponent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit, Inject, Input, Output, EventEmitter, NgModule, ViewEncapsulation, asNativeElements } from '@angular/core'; | |
@Component({ | |
encapsulation: ViewEncapsulation.Emulated, | |
selector: 'app-sample-form-component', | |
template: ` | |
<input #myIput type="text" [(ngModel)] = "message" [ngClass] = "{mouseclickedClass:ismouseclicked}" | |
(click)="mouseclick()" (mouseout)="ismouseclicked = false"> | |
<button class="white bg-red code" (click)="update.emit({text:message})"> click Me!</button> | |
`, | |
styles: [ ` | |
:host{ | |
display : flex; | |
flex-direction : column; | |
} | |
input:focus{ | |
font-weight: bold; | |
outline: none; | |
} | |
.mouseclickedClass{ | |
border : 3px solid yellow; | |
} | |
button{ | |
border: none; | |
} | |
` | |
] | |
}) | |
export class SampleFormComponentComponent implements OnInit { | |
@Input() message = ''; | |
@Output() update = new EventEmitter(); | |
public ismouseclicked = false; | |
constructor( | |
@Inject('sharedservices') public sharedservices, | |
@Inject('sharevalue') public sharevalue) { } | |
ngOnInit(): void { | |
} | |
mouseclick(){ | |
this.ismouseclicked = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment