This repository has been archived by the owner on Jul 10, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a form to home page to support parsing (#8)
* Adding a form to home page to support parsing * Fixing CSS whitespace * Fixing tests
- Loading branch information
Showing
7 changed files
with
68 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
<p> | ||
home-page works! | ||
</p> | ||
<input type="text" id="ingredientRaw" placeholder="Enter an ingredient to parse" [(ngModel)]="ingredientRaw"> | ||
<input type="submit" value="Parse" name="Parse" (click)="parse(ingredientRaw)" /> | ||
<ul *ngIf="ingredientParsed"> | ||
<li><span class="fieldName">Quantity</span>: {{ ingredientParsed.quantity }}</li> | ||
<li><span class="fieldName">Unit</span>: {{ ingredientParsed.unit }}</li> | ||
<li><span class="fieldName">Name</span>: {{ ingredientParsed.name }}</li> | ||
<li><span class="fieldName">Other</span>: {{ ingredientParsed.other }}</li> | ||
<li><span class="fieldName">Comment</span>: {{ ingredientParsed.comment }}</li> | ||
</ul> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
span.fieldName { | ||
font-weight: bold; | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,28 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { IngredientParsed } from '../../_models/parse-result'; | ||
import { ParserService } from '../../_services/parser.service'; | ||
|
||
@Component({ | ||
selector: 'app-home-page', | ||
templateUrl: './home-page.component.html', | ||
styleUrls: ['./home-page.component.scss'], | ||
}) | ||
export class HomePageComponent implements OnInit { | ||
ingredientRaw: string; | ||
ingredientParsed: IngredientParsed; | ||
|
||
constructor() { } | ||
constructor(private parserService: ParserService) { } | ||
|
||
ngOnInit() { | ||
ngOnInit() {} | ||
|
||
parse(raw: string) { | ||
this.parserService.parseIngredient(raw).subscribe( | ||
(response) => { | ||
this.ingredientParsed = response.ingredientParsed; | ||
}, | ||
(error) => { | ||
console.log(error); | ||
}); | ||
} | ||
|
||
} |