Angular πŸ‡ΊπŸ‡¦ - practical notes
1.63K subscribers
1.6K photos
1 file
532 links
Angular - practical notes

This group is for posting practical notes for Angular developers. Mostly all posts are for quick implementation https://t.me/angular_practical_notes (Commenting on posts only in ENG and UA langs here). Welcome!
Download Telegram
js.reduce(): Split array into chunks

#js #reduce

βœ… Example:

function Chunk(array, size) {
return array.reduce((acc, _, index) => {
if (index % size === 0) acc.push(array.slice(index, index + size));
return acc;
}, []);
}

const numbers = [1, 2, 3, 4, 5, 6, 7];
const arr3 = Chunk(numbers, 2);
// Output: arr3: [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ], [ 7 ] ]
Factory async function with ability of cancelling

#js #promise #AbortController

function asyncWithAbort(promiseFn, signal){
if (signal?.aborted){
return Promise.reject(new DOMException("Aborted", "AbortError"));
}
return new Promise((resolve, reject) => {
promiseFn().then(resovle).catch(reject);

signal?.addEventListener("abort", () => {
reject(new DOMException("Aborted", "AbortError"));
});
});
}

βœ… Link: https://javascript.plainenglish.io/best-practices-for-using-abortcontroller-87892b72d07e
withComponentInputBinding in Angular

Angular v16 has introduced a powerful new feature that enables the automatic binding of router information, such as query parameters, path parameters, static data, and resolver data to a routed component’s inputs.

#angular #routing #withComponentInputBinding

🚩 > Angular 16

βœ… Link: https://netbasal.com/binding-router-information-to-routed-component-inputs-in-angular-78ee92f63e64