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
<table> | |
<tr> | |
<td>Topic: </td> | |
<td><input [(ngModel)]="topicname" type="text" /></td> | |
<td><button type="button" (click)="subscribeNewTopic()">Subscribe Topic</button></td> | |
</tr> | |
<tr> | |
<td>Message: </td> | |
<td><input [(ngModel)]="msg" type="text" /></td> | |
<td><button type="button" (click)="sendmsg()">Send</button></td> |
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 { BrowserModule } from '@angular/platform-browser'; | |
import { NgModule } from '@angular/core'; | |
import { FormsModule } from "@angular/forms"; | |
import { AppComponent } from './app.component'; | |
import { MqttModule, IMqttServiceOptions } from "ngx-mqtt"; | |
export const MQTT_SERVICE_OPTIONS: IMqttServiceOptions = { | |
hostname: 'localhost', | |
port: 9001, | |
path: '/mqtt' | |
} |
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, ViewChild, ElementRef, OnDestroy } from '@angular/core'; | |
import { Subscription } from 'rxjs'; | |
import { IMqttMessage, MqttService } from 'ngx-mqtt'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'] | |
}) | |
export class AppComponent implements OnInit, OnDestroy { | |
private subscription: Subscription; |
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 } from '@angular/core'; | |
import { FormControl, FormGroup } from '@angular/forms'; | |
import { equalPassValidator } from './shared/equal.validator.directive'; | |
@Component({ | |
selector: 'my-app', | |
templateUrl: './app.component.html', | |
styleUrls: [ './app.component.css' ] | |
}) | |
export class AppComponent { |
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 { Validator, AbstractControl, NG_VALIDATORS, ValidatorFn } from '@angular/forms'; | |
import { Directive, Input } from "@angular/core"; | |
export function equalPassValidator(appEqualValidator: string): ValidatorFn { | |
return (c: AbstractControl): { [key: string]: any | null } => { | |
console.log("control object: ", c, appEqualValidator) | |
const controlToCompare = c.root.get(appEqualValidator); | |
console.log('control to compare: ', controlToCompare); | |
if (controlToCompare && controlToCompare.value === c.value) return { "equal": true }; | |
return { "equal": false } |
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
<form [formGroup]="signUpForm"> | |
<table> | |
<tr> | |
<td> | |
<label>Username:</label> | |
</td> | |
<td> | |
<input name="username" type="text" formControlName="username"> | |
</td> | |
</tr> |
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 } from '@angular/core'; | |
import { FormControl, FormGroup } from '@angular/forms'; | |
@Component({ | |
selector: 'my-app', | |
templateUrl: './app.component.html', | |
styleUrls: [ './app.component.css' ] | |
}) | |
export class AppComponent { | |
name = 'Angular'; |
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 { NgModule } from '@angular/core'; | |
import { BrowserModule } from '@angular/platform-browser'; | |
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; | |
import { AppComponent } from './app.component'; | |
import { HelloComponent } from './hello.component'; | |
import { EqualValidatorDirective } from './shared/equal.validator.directive'; | |
@NgModule({ | |
imports: [ BrowserModule, FormsModule, ReactiveFormsModule ], |
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.state = { | |
scrollPosition: 0 | |
} | |
componentWillReceiveProps () { | |
const element = ReactDOM.findDOMNode(this); | |
if (element != null) { | |
this.setState({ | |
scrollPosition: window.scrollY | |
}) |
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
//Pass the orderItems array that you get | |
getDataArray(arr) { | |
const uniqByArr = uniqBy(arr, 'item_id'); | |
let finalArr = []; | |
uniqByArr.map((item,idx) => { | |
const item_id = item.item_id; | |
let qty = 0; | |
arr.map((actualItem) => { | |
if (item_id === actualItem.item_id) { | |
qty += 1; |