Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Different views for Desktop and mobile Angular

// Route guards would be a good solution for this purpose.

// The MobileGuard would look like this :

export class MobileGuard implements CanActivate {
    constructor(private _router: Router, private _mobileService: MobileService) {}

    canActivate(): boolean {
        const isMobile = this._mobileService.isMobile();
        if(!isMobile) {
            this._router.navigate(['/desktop']);
        }
        return isMobile;
    }
}
// The same for the DesktopGuard.

// The user trying to access any of the routes, would be redirected to the right one.

Comment

PREVIOUS NEXT
Code Example
Javascript :: pwa cache viewer 
Javascript :: check if computer online js 
Javascript :: js ctx dash line 
Javascript :: vbscript popup message box with timer 
Javascript :: generate svg from javascript 
Javascript :: git reset local branch to origin 
Javascript :: sumar un mes a una fecha javascript moment 
Javascript :: how to add all files in a director to an array in javascript 
Javascript :: let a = {y;10}; 
Javascript :: angular dropdown selected value 
Javascript :: async await 
Javascript :: mongooseautoincrement 
Javascript :: jquery get id of 3rd parent 
Javascript :: videojs videoJsResolutionSwitcher youtube 
Javascript :: angular 8 remove cookies 
Javascript :: react native swipe screen 
Javascript :: JavaScript alert massage prompt 
Javascript :: ejs js 
Javascript :: ReactDOM render in v18 
Javascript :: calculate age given the birth date in the format yyyymmdd 
Javascript :: javascript round down to 2 decimal places 
Javascript :: react hooks example 
Javascript :: index and id togtgher angularjs 
Javascript :: noscript tag code string in react 
Javascript :: loading screen html css js 
Javascript :: shopify guest login 
Javascript :: how to remove only green background from video using ffmeg nodejs 
Javascript :: basic react code 
Javascript :: jvectormap color regions 
Javascript :: delete character between index 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =