我需要允许我的应用程序的用户在他们想要的时候更改默认路由:我有一个参数页面,他们可以在登录时选择他们想要首先显示的"页面".
例如,当他们登录时,他们会重定向到Day,但是他们希望能够更改它并在他们登录时的周或月重定向.
{ path: 'planification', component: PlanificationComponent,
children: [
{ path: '', redirectTo: 'Day', pathMatch: 'full' },
{ path: 'day', component: DayComponent },
{ path: 'week', component: WeekComponent },
{ path: 'month', component: MonthComponent }]
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
@ angular/core:2.4.7
@ angular/router:3.4.7
谢谢你的帮助!
我目前正在尝试表头粘性。我已经实现了它,但问题是当我滚动表格时,粘性表格标题变得透明。

我不知道如何避免这种透明度。请任何人都可以帮助我。
.table-sticky {
overflow: auto;
height: 79vh;
display: inline-block;
}
.spread-table th {
padding-bottom: 12px;
background-color: green;
position: sticky;
top: 0;
}
<div class="table-sticky">
<table class="spread-table" #spreadTable>
<thead>
<tr>
<th id="line-item-header" class="line-item-header">
<button class="header-button line-item-header"></button>
</th>
<th *ngFor="let spreadColumn of spreadColumns">
<button>{{spreadColumn}}</button></th>
</tr>
</thead>
<tbody *ngFor="let lineitem of dataSource; let i = index">
<tr>
<td>
<app-child-table [items]="lineitem.children">
</app-child-table>
</td>
</tr>
<tr>
<td class="line-item-data">
<mat-form-field>
<input matInput [value]="lineitem.lineItem" [id]="'line_'+lineitem.id">
</mat-form-field>
</td>
<td *ngFor="let spreadColumn of spreadColumns">
<mat-form-field>
<input matInput [id]="lineitem.id+'_line_'+spreadColumn" …Run Code Online (Sandbox Code Playgroud) 我正在尝试有关 Highcharts 的演示应用程序。我从两个网站找到了相同的代码并尝试了它,但在两个网站中我都继续捕获相同的错误。
ERROR in src/app/app.module.ts:11:5 - error NG6001: Cannot declare 'Highchar
tsChartComponent' in an NgModule as it's not a part of the current compilation.
11 HighchartsChartComponent
~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/highcharts-angular/lib/highcharts-chart.component.d.ts:4:22
4 export declare class HighchartsChartComponent implements OnDestroy {
~~~~~~~~~~~~~~~~~~~~~~~~
'HighchartsChartComponent' is declared here.
src/app/app.component.html:3:1 - error NG8001: 'highcharts-chart' is not a k
nown element:
1. If 'highcharts-chart' is an Angular component, then verify that it is par
t of this module.
2. If 'highcharts-chart' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA …Run Code Online (Sandbox Code Playgroud) 我正在尝试开发 Web Api (NET CORE) 可插件应用程序的前端。我想使用 Angular 9,但我不是 Angular 专家。
我的后端被设计为可扩展的,在启动时它会在指定的文件夹中监视,如果存在一个或多个包含扩展基本应用程序(如插件)逻辑的 dll 文件,它会加载它们。我想在前端使用类似的方法。我尝试了不同的解决方案并阅读了很多文章,但很难找到想要在编译时导入未知插件的人。
我尝试了懒惰的模块(从这个开始:https : //www.mokkapps.de/blog/manually-lazy-load-modules-and-components-in-angular/)这将是完美的,但使用这个我必须知道实现插件(模块)在编译我的 angular 应用程序之前,因为如果我想使用模块,我必须在我的主应用程序中使用导入功能。
因此,我进行了更多搜索,在使用 Angular CLI 和 Angular 5 在运行时动态加载新模块一文之后,我尝试了 System.Js 方法,但找不到适用于 angular 9 的解决方案。
我很确定我不是唯一一个会创建可插入的 Angular 应用程序的人,该应用程序无需重新编译主应用程序即可加载插件。
我需要一些关于正确方法的建议,或者一个使用插件架构的 angular 应用程序的工作示例。
我是这个平台的新手。
我安装了Node.js但是当我尝试运行命令npm install -g @angular/cli 时
我收到了这个错误:
**npm WARN deprecated mkdirp@0.5.3: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN rollback Rolling back @schematics/angular@9.0.6 failed (this is probably harmless): EPERM: operation not permitted, lstat 'C:\Users\Vivek\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@sche**
Run Code Online (Sandbox Code Playgroud)
此外,当我尝试运行版本命令时
它向我展示了
**C:\Users\Vivek>ng v
internal/modules/cjs/loader.js:985
throw err;
^
Error: Cannot find module 'C:\Users\Vivek\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng'**
Run Code Online (Sandbox Code Playgroud) 在另一个组件中注入组件来访问注入组件中的函数或属性是否正确?
注意:这些组件都不是另一个组件的子组件
import { UsersComponent } from './../users/users.component';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {
constructor(users:UsersComponent){
users.getAllUsers()
}
}
Run Code Online (Sandbox Code Playgroud) 我已经遇到同样的问题几个月了,但仍然找不到解决方案。我有一个应用程序,其中有多种表单,当专注于输入字段时,键盘会覆盖该输入字段,并且用户看不到任何内容。这只发生在iOS上,在Android上一切正常。
在此应用中,我使用带有电容器的 ionic 5。
这就是我希望我的应用程序工作的方式:示例 1
目前它的工作原理如下:示例2
.HTML
<form [formGroup]="formSubmit" (ngSubmit)="formSubmit()">
<mat-form-field appearance="outline" class="field-style">
<input matInput maxlength="35" class="input-form" placeholder="Agregar un alias (opcional)" formControlName="alias">
</mat-form-field>
<button mode="ios" class="btn-siguiente-enable" expand="block" type="submit" *ngIf="formSubmit.valid">Siguiente</button>
</form>
Run Code Online (Sandbox Code Playgroud)
.TS
ngOnInit() {
this.initForms();
Plugins.Keyboard.setScroll({isDisabled: true});
Plugins.Keyboard.addListener('keyboardWillShow', (info: KeyboardInfo) => {
Plugins.Keyboard.setResizeMode({mode: KeyboardResize.None});
});
Plugins.Keyboard.addListener('keyboardWillHide', () => {
Plugins.Keyboard.setResizeMode({mode: KeyboardResize.Native});
});
}
Run Code Online (Sandbox Code Playgroud)
知道如何解决这个问题吗?
我正在尝试使用本指南https://github.com/atularen/ngx-monaco-editor#readme将 Monaco Editor 嵌入到我正在开发的 Web 应用程序中。我尝试添加ngx-monaco-editor标签,但 Angular 给了我这个错误。关于如何解决这个问题有什么想法吗?
ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError(EditorModule)[InjectionToken NGX_MONACO_EDITOR_CONFIG -> InjectionToken NGX_MONACO_EDITOR_CONFIG -> InjectionToken NGX_MONACO_EDITOR_CONFIG -> InjectionToken NGX_MONACO_EDITOR_CONFIG]: \n NullInjectorError: No provider for InjectionToken NGX_MONACO_EDITOR_CONFIG!\nNullInjectorError: R3InjectorError(EditorModule)[InjectionToken NGX_MONACO_EDITOR_CONFIG -> InjectionToken NGX_MONACO_EDITOR_CONFIG -> InjectionToken NGX_MONACO_EDITOR_CONFIG -> InjectionToken NGX_MONACO_EDITOR_CONFIG]: \n NullInjectorError: No provider for InjectionToken NGX_MONACO_EDITOR_CONFIG!\n at NullInjector.get (core.js:915)\n at R3Injector.get (core.js:11082)\n at R3Injector.get (core.js:11082)\n at R3Injector.get (core.js:11082)\n at NgModuleRef$1.get (core.js:24199)\n at R3Injector.get (core.js:11082)\n at NgModuleRef$1.get (core.js:24199)\n at Object.get (core.js:22102)\n at …Run Code Online (Sandbox Code Playgroud) angularjs typescript monaco-editor angular ngx-monaco-editor
如何从keycloak服务器获取 access_token 到我的授权组件。授权 URL 如下所示:
回调 url 位于http://localhost:4200/auth,这是组件:
import { Component, OnInit } from '@angular/core';
import {ActivatedRoute} from '@angular/router';
@Component({
selector: 'app-auth',
templateUrl: './auth.component.html',
styleUrls: ['./auth.component.scss']
})
export class AuthComponent implements OnInit {
constructor(private route: ActivatedRoute) { }
ngOnInit() {
console.log(this.route.snapshot);
console.log(this.route.snapshot);
}
}
Run Code Online (Sandbox Code Playgroud)
登录成功后, keycloak会返回 access_token ,如下所示:
http://localhost:4200/auth#access_token=qwerty123&session_time=123456789
我的问题是,如何让它发挥作用并获取 access_token。
我正在尝试根据 Angular 11 应用程序中 pdfMake 的官方文档定义 pdf 文档结构。但收到错误:
error TS2345: Argument of type '{ pageSize: string; pageOrientation: string; content: ({ text: string; style: string; fontSize?: undefined; } | { text: string; fontSize: number; style?: undefined; })[]; }' is not assignable to parameter of type 'TDocumentDefinitions'.
Types of property 'pageOrientation' are incompatible.
Type 'string' is not assignable to type '"landscape" | "portrait" | undefined'.
75 pdfMake.createPdf(docDefinition).open();
Run Code Online (Sandbox Code Playgroud)
我已经安装了所有人员:
npm install --save pdfmake
npm i --save-dev @types/pdfmake
Run Code Online (Sandbox Code Playgroud)
并导入它们:
import * as pdfMake from …Run Code Online (Sandbox Code Playgroud) angular ×10
typescript ×3
angular-cli ×1
angular7 ×1
angularjs ×1
css ×1
highcharts ×1
html ×1
ionic-native ×1
ionic4 ×1
javascript ×1
node.js ×1
npm ×1
pdfmake ×1
sass ×1
system.js ×1
web-frontend ×1