Part of Web APIs for Angular
A set of common utils for consuming Web APIs with Angular
WINDOW
— provides access to globalwindow
objectNAVIGATOR
— provides access towindow.navigator
objectNETWORK_INFORMATION
— provides access towindow.navigator.connection
objectUSER_AGENT
— provides access towindow.navigator.userAgent
stringPERFORMANCE
— provides access towindow.performance
objectANIMATION_FRAME
— shared Observable based onwindow.requestAnimationFrame
CSS
— provides access towindow.CSS
object or mock object if it's not available (i.e. in IE)LOCATION
— provides access towindow.location
objectLOCAL_STORAGE
— provides access towindow.localStorage
objectSESSION_STORAGE
— provides access towindow.sessionStorage
objectSPEECH_RECOGNITION
— provides access toSpeechRecognition
class or returnsnull
if browser does not support itSPEECH_SYNTHESIS
— provides access towindow.speechSynthesis
objectPAGE_VISIBILITY
— wrapper fordocument.addEventListener('visibilityChange')
api
Just inject a token you need. You can also take a look at Stackblitz sample
- It is easy to understand: you see all dependencies of your entity in its constructor
- It is easy to test: you can just mock any of your dependencies to test
- It is easy to reuse: your components and directives can be used in any context if it has dependencies that they need to be created
- It is enviroment agnostic: you can start your app in SSR or other environments (see also @ng-web-apis/universal)
Other Web APIs for Angular by @ng-web-apis