官术网_书友最值得收藏!

Laying out the UI

We will use angular-material once more as described in the preceding example. So, install and use the components as you see fit to style your application's UI:

npm install --save @angular/material @angular/animations @angular/cdk

We will use MatGridListModule to create our application's UI. After importing it in the main module, we can create the template as follows:

<mat-grid-list cols="2" rowHeight="2:1">
<mat-grid-tile>
<textarea (keyup)="codeChange()" [(ngModel)]="code"></textarea>
</mat-grid-tile>
<mat-grid-tile>
<div>
Result: {{result}}
</div>
</mat-grid-tile>
</mat-grid-list>

We are laying down two tiles; the first one contains the textarea to write the code and the second one displays the result generated.

We have bound the input area with ngModel, which is going to provide the two-way binding that we need between our view and the component. Further, we leverage the keyup event to trigger the method called codeChange(), which will be responsible for passing our expression into the worker.

The implementation of the codeChange() method will be relatively easy.

主站蜘蛛池模板: 崇礼县| 黑水县| 长春市| 桂林市| 连南| 鄂伦春自治旗| 曲阳县| 交城县| 贡觉县| 新安县| 靖边县| 张北县| 霍山县| 拜城县| 云龙县| 中超| 平定县| 独山县| 竹北市| 峨眉山市| 贵港市| 修水县| 阳城县| 宜州市| 繁昌县| 彩票| 南昌县| 漳浦县| 高碑店市| 弥渡县| 七台河市| 晋宁县| 班戈县| 屏南县| 伊通| 成武县| 石河子市| 宁远县| 长子县| 禹州市| 高邑县|