Skip to content

Instantly share code, notes, and snippets.

@KingDarBoja
Created March 4, 2019 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KingDarBoja/0b39b2a4a67b689dd613f90a64683549 to your computer and use it in GitHub Desktop.
Save KingDarBoja/0b39b2a4a67b689dd613f90a64683549 to your computer and use it in GitHub Desktop.
Main Dart file implementing the AuthGuard
import 'package:angular/angular.dart';
import 'package:web/app.component.template.dart' as ng;
import 'package:angular_router/angular_router.dart';
import 'package:web/guards/auth.guard.dart';
// Import the main.dart file to reference it within the program as “self”
import 'main.template.dart' as self;
const bool useHashLS = false;
// This section provides the Dependency Injector "routerProviders"
// available to every component within our program.
@GenerateInjector([
routerProvidersHash,
ClassProvider(AuthGuard),
ExistingProvider(RouterHook, AuthGuard)
])
// Generates an Injector Factory at compile time.
// $Injector is used to retrieve object instances as defined by router provider.
// self.injector references to the main file referencing the Injector.
final InjectorFactory injector = self.injector$Injector;
// Create the Injector.
void main() {
runApp(ng.AppComponentNgFactory, createInjector: injector);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment