Created
October 17, 2018 14:42
-
-
Save SharanGoharKhan/e388ed33c62b3b229fa80df61424dd5d to your computer and use it in GitHub Desktop.
todo-input component
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
.container { | |
display: flex; | |
justify-content: center; | |
margin-bottom: 39px; | |
} | |
.todo--input { | |
width: 40%; | |
padding: 12px 20px; | |
border: 1px solid #ccc; | |
border-radius: 4px; | |
font-size: 20px; | |
} | |
.container .save { | |
background-color: var(--btn-save-color); | |
} | |
.todo--input:hover { | |
box-shadow: var(--primary-shadow); | |
} | |
.container .btn:hover { | |
box-shadow: var(--primary-shadow); | |
} | |
.container .btn[disabled], | |
.container .btn[disabled]:hover { | |
cursor: not-allowed; | |
background-color: var(--btn-delete-color); | |
box-shadow: none; | |
} |
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
<div class="container"> | |
<input | |
[(ngModel)]="todo" | |
type="text" | |
placeholder="Enter Todo" | |
class="todo--input"/> | |
<button | |
[disabled]="todo == ''" | |
type="button" | |
class="btn save" | |
(click)="onSaveTodo()">Save Todo!</button> | |
</div> |
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, Output, EventEmitter } from '@angular/core'; | |
@Component({ | |
selector: 'app-todo-input', | |
templateUrl: './todo-input.component.html', | |
styleUrls: ['./todo-input.component.css'] | |
}) | |
export class TodoInputComponent { | |
// tslint:disable-next-line:no-output-on-prefix | |
@Output() onTodoAdd: EventEmitter<any> = new EventEmitter<any>(); | |
todo: String = '' ; | |
onSaveTodo() { | |
this | |
.onTodoAdd | |
.emit(this.todo); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment