问题描述
我有一种chatbotComponent
并没有附加到任何路由配置中。
@Component({
selector: 'app-chatbot',templateUrl: './chatbot.component.html',styleUrls: ['./chatbot.component.css'],providers: [UseRSService,OrganizationService]
})
该指令在app模块的app.compononent.html下调用:
<app-logo></app-logo>
<router-outlet></router-outlet>
<app-footer></app-footer>
<app-chatbot></app-chatbot>
这是我的routing.yaml
const routes: Routes = [
{ path: '',component: LoginComponent,pathMatch: 'full',canActivate: [AuthenticationGuard]},{ path: 'accueil',component: AccueilComponent,canActivate: [AuthenticationGuard] },{ path: '**',redirectTo: '' }
];
@NgModule({
imports: [ RouterModule.forRoot(routes) ],exports: [ RouterModule ]
})
我要问有什么方法可以通过我的chatbotComponent
保护AuthenticationGuard
,以便阻止在组件下触发的api调用!
这是关于我的依赖关系的一个简短愿景:
+-- @angular/[email protected]
+-- @angular/[email protected]
| +-- @angular-devkit/[email protected]
| +-- @angular-devkit/[email protected]
| +-- @angular-devkit/[email protected]
| +-- @schematics/[email protected]
+-- @angular/[email protected]
+-- @angular/[email protected]
+-- @angular/[email protected]
+-- @angular/[email protected]
+-- @angular/[email protected]
+-- @angular/[email protected]
+-- @angular/[email protected]
+-- @angular/platform-bro[email protected]
+-- @angular/platform-bro[email protected]
+-- @angular/[email protected]
+-- [email protected]
谢谢
解决方法
您可以简单地使用import math
print(math.pi)
*ngIf
应在app.component.ts中定义<app-chatbot *ngIf="isAuthenticated"></app-chatbot>
的位置,如果用户已通过身份验证,则应分配isAuthenticated
,否则应分配true
。
编辑: 例如在您的app.component.ts
中false