import { Injectable } from '@angular/core' ; import { CanActivate } from '@angular/router' ; import { RouterExtensions } from '@nativescript/angular' ; import { BeancountFileService } from '../shared/beancount-file.service' ; @ Injectable ( { providedIn : 'root' , } ) export class WelcomeGuard implements CanActivate { constructor ( private beancountFile , private router ) { } canActivate ( ) { if ( this . beancountFile . path ) { this . router . navigate ( [ '/plaintext' ] ) ; return false ; } else { return true ; } } }