可使用 Angular CLI 透過指令 ng generate guard auth/auth 建立。
ng generate guard auth/auth
method 依靠回傳值作為是否能進入該頁面的判斷條件,可使用型態:
於定義 routing list 的時候指定要使用指定 guard 的特定 method,如
{ path: "pages", canActivate: [AuthGuard], loadChildren: () => import("./pages/pages.module").then((m) => m.PagesModule), }
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up