Skip to content

Instantly share code, notes, and snippets.

@SandeepThomas
SandeepThomas / socket.service.ts
Created Nov 15, 2018
Angular RxJs Websocket
View socket.service.ts
import { Injectable } from '@angular/core';
import { fromEvent, NextObserver, Observable, Subject, Subscription, timer } from 'rxjs';
import { _throw } from 'rxjs/observable/throw';
import { finalize, mergeMap, retryWhen, take } from 'rxjs/operators';
import { WebSocketSubject } from 'rxjs/webSocket';
import { environment } from '../../../environments/environment';
import { AuthService } from './authentication.service';
@Injectable()
export class SocketService {
@SandeepThomas
SandeepThomas / translate.loader.ts
Last active Nov 14, 2018
ngx translate custom loader
View translate.loader.ts
/*
* Custom Translate Loader to reload lang JSON on network failure
*/
import { TranslateLoader } from "@ngx-translate/core";
import { Injectable } from "@angular/core";
import { HttpHeaders, HttpClient } from "@angular/common/http";
import { ConnectionService } from ".";
import { Observable } from "rxjs";
import { filter, take } from "rxjs/operators";
View routes
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AuthGuard, SocketInitialize } from './shared/services/authguard.service';
const APP_ROUTES: Routes = [
{ path: '', loadChildren: './landing/landing.module#LandingModule' },
{ path: 'home', loadChildren: './home/home.module#HomeModule', canActivate: [AuthGuard, SocketInitialize] },
{ path: '**', redirectTo: '' }
];
@SandeepThomas
SandeepThomas / datepickerLocaldateDirective.js
Last active Mar 8, 2021 — forked from weberste/gist:354a3f0a9ea58e0ea0de
Dates only with Angular-UI Bootstrap datepicker - In Epoch time / Unix time
View datepickerLocaldateDirective.js
app.directive('datepickerLocaldate', ['$parse', function ($parse) {
var directive = {
restrict: 'A',
require: ['ngModel'],
link: link
};
return directive;
function link(scope, element, attr, ctrls) {
var ngModelController = ctrls[0];