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
Making a phone call from app | |
<a href="tel:+9876543210">9876543210</a> | |
The launching of external pages can be done directly from your view. Take the following example: | |
- window.open(‘http://example.com’, ‘_system’); Loads in the system browser | |
- window.open(‘http://example.com’, ‘_blank’, 'location=yes'); Loads in the InAppBrowser | |
- window.open(‘http://example.com’, ‘_blank’, ‘location=no’); Loads in the InAppBrowser with no location bar | |
- window.open(‘http://example.com’, ‘_self’); Loads in the Cordova web view |
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
// Filter in array | |
let a = [0, 1, '', true, false, null, "DSDS", "1", "0"]; | |
a.filter(Boolean); // [1, true, "DSDS", "1", "0"] | |
// Sorting an array | |
var a = [1,3,2,5,33,22,32]; | |
a.sort((a, b) => a — b); // [1, 2, 3, 5, 22, 32, 33] |
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
let a = [0, 1, '', true, false, null, "DSDS", "1", "0"]; | |
a.filter(Boolean); // [1, true, "DSDS", "1", "0"] |
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
// merge an array of objects | |
const data = [ {a: 1}, {b: 2}, {c: 3} ] | |
const merged = data.reduce((res, obj) => ({...res, ...obj}), {}) | |
console.log(merged) // => { a: 1, b: 2, c: 3 } | |
// merge an array of objects by property | |
const toMerge = [ | |
{ id: 1, value: 'a', }, | |
{ id: 2, value: 'b', }, | |
{ id: 3, value: 'c' }, |
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
const a = { | |
foo: 'bar', | |
useful: 1, | |
useless: 2 | |
} | |
const {useless, ...clean} = a; | |
console.log(clean); // {foo: 'bar', useful: 1} |
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
const initial = [ {id: 1, score: 1}, {id: 2, score: 2}, {id: 3, score: 4}] | |
const removeId = 3 | |
const without3 = initial.filter(x => x.id !== removeId) | |
console.log(without3) // => [ { id: 1, score: 1 }, { id: 2, score: 2 } ] |
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
const initial = [ {id: 1, score: 1}, {id: 2, score: 2}, {id: 3, score: 4}] | |
const newValue = {id: 3, score: 3} | |
const updated = initial.map(x => x.id === newValue.id ? newValue : x) | |
console.log(updated) // => [ { id: 1, score: 1 }, { id: 2, score: 2 }, { id: 3, score: 3 } ] |
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 { Pipe, PipeTransform } from '@angular/core'; | |
/* | |
* Changes the case of the first letter of a given number of words in a string. | |
*/ | |
@Pipe({ name: 'titleCase', pure: false }) | |
export class TitleCase implements PipeTransform { | |
transform(input: string, length: number): string { | |
return input.length > 0 ? input.replace(/\w\S*/g, (txt => txt[0].toUpperCase() + txt.substr(1).toLowerCase())) : ''; |
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
/* | |
* component file code | |
*/ | |
/* | |
* IMAGE UPLOAD SECTION | |
*/ | |
public takePicture(sourceType) { |