number field
This commit is contained in:
parent
4bae0eeb61
commit
ab2a25d324
@ -13,4 +13,16 @@
|
||||
<ledbutton topic="led/test4" label="test4"></ledbutton>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<app-number-field topic="number/test1"></app-number-field>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
@ -6,6 +6,7 @@ import { AppComponent } from './app.component';
|
||||
import { LedindicatorComponent } from './ledindicator/ledindicator.component';
|
||||
import { OnOffButtonComponent } from './on-off-button/on-off-button.component';
|
||||
import { LedButtonGroupComponent } from './led-button-group/led-button-group.component';
|
||||
import { NumberFieldComponent } from './number-field/number-field.component';
|
||||
|
||||
|
||||
@NgModule({
|
||||
@ -13,7 +14,8 @@ import { LedButtonGroupComponent } from './led-button-group/led-button-group.com
|
||||
AppComponent,
|
||||
LedindicatorComponent,
|
||||
OnOffButtonComponent,
|
||||
LedButtonGroupComponent
|
||||
LedButtonGroupComponent,
|
||||
NumberFieldComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule
|
||||
|
25
src/app/number-field/number-field.component.spec.ts
Normal file
25
src/app/number-field/number-field.component.spec.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { NumberFieldComponent } from './number-field.component';
|
||||
|
||||
describe('NumberFieldComponent', () => {
|
||||
let component: NumberFieldComponent;
|
||||
let fixture: ComponentFixture<NumberFieldComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ NumberFieldComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(NumberFieldComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
23
src/app/number-field/number-field.component.ts
Normal file
23
src/app/number-field/number-field.component.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { MqttclientService } from '../mqttclient.service'
|
||||
|
||||
@Component({
|
||||
selector: 'app-number-field',
|
||||
template: `
|
||||
<span>{{value}}</span>
|
||||
`
|
||||
})
|
||||
export class NumberFieldComponent implements OnInit {
|
||||
|
||||
@Input() topic : string
|
||||
value: number
|
||||
|
||||
constructor(private mqttclientService : MqttclientService) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.mqttclientService.register(this.topic, (message: string) => {
|
||||
this.value = parseInt(message)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user