Skip to content

Instantly share code, notes, and snippets.

View YonathanMeguira's full-sized avatar
🤩
Happy

Yonathan Meguira YonathanMeguira

🤩
Happy
View GitHub Profile
<div *ngFor="let element of myArray; let idx = index">
<input name="someName" [(ngModel)] = "myArray[idx]">
</div>
@YonathanMeguira
YonathanMeguira / interceptor.ts
Created January 31, 2018 12:31
http interceptor
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import {
HttpEvent,
HttpHandler,
HttpInterceptor,
HttpRequest
} from '@angular/common/http';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
/* Angular Modules */
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { FormsModule } from '@angular/forms';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { AppComponent } from './app.component';
@YonathanMeguira
YonathanMeguira / app.component.ts
Created January 31, 2018 12:39
add the interceptor
import { Component, AfterViewInit, ViewChild, ElementRef } from '@angular/core';
import { HTTPStatus } from './services/RxJS/HTTPListener.service';
declare var bodymovin: any;
@Component({
selector: 'app-root',
template: `<div [hidden] = !HTTPActivity`,
styleUrls: ['./app.component.css']
})
export class AppComponent {
@YonathanMeguira
YonathanMeguira / buttons.css
Created February 20, 2018 12:21
cool buttons
/* orange to red buttons with animation on hover */
.warm-btn{
padding: 10px 20px;
font-weight: 600;
color: #ff386a;
border: solid 1px #ff386a;
text-transform: uppercase;
font-size: 0.9em;
background-color: transparent;
@YonathanMeguira
YonathanMeguira / instructions.txt
Created February 25, 2018 14:00
instructions for Monday 26/02/2018
1) add a button " Visibility Point Query"
click on this button should :
-disable the tilting and orbit controls of the scene
- capture any click on the screen and only draw the last clicked point
- transform window x, y to world coordinates
- the button is inversed to "Query visibility", click on this button sends the last clicked point to the server and shows a loader
2) add a button "Path Visibility"
clicking on this button has the same effect as previously but:
all points are drawn onto the scene, need to link the points between them, (draw vectors by couples of {x, y}), if the first couple and the last couple (last clicked point)
@YonathanMeguira
YonathanMeguira / service.ts
Created March 14, 2018 10:12
Http service angular 5
goToServer = () => {
this.http.get('url');
}
getInformtionFromService = () => {
service.goToServer().subscribe(result => console.log(result), error => console.log(error.message))
}
@YonathanMeguira
YonathanMeguira / Input-decoractor-changes.ts
Last active March 14, 2018 13:03
watch changes in input decorators
// set up some class with an input decorator (the one we want to watch and act upon change
export class MyComponent {
myBooleanValue: boolean;
@Input()
set myBooleanValue(newValue: boolean) {
// will display this message as soon as the value of 'myBooleanValue' changes
console.log(`old value was ${this.booleanValue}, new value is ${newValue}`;
this.myBooleanValue = newValue;
@YonathanMeguira
YonathanMeguira / tmpl.html
Created March 14, 2018 13:04
watching decorator @input changes template
<my-component [myBooleanValue]="someValue"></my-component>
@YonathanMeguira
YonathanMeguira / pipeSize.pipe.ts
Created March 18, 2018 12:28
fileSize pipe angular 5
import { Pipe, PipeTransform } from '@angular/core';
/*
* Convert bytes into largest possible unit.
* Takes an precision argument that defaults to 2.
* Usage:
* bytes | fileSize:precision
* Example:
* {{ 1024 | fileSize}}
* formats to: 1 KB