我刚刚注意到 Angular 8(即将发布)已经弃用了“字符串类型路由器loadChildren”。(门票)
我是否正确理解他们指的是......
const routes = [
{
path: 'production',
loadChildren: './production/production.module#ProductionModule' // <<--this
}],
Run Code Online (Sandbox Code Playgroud)
要迁移到 Angular 8,解决方案是什么?
在票证中,他们指的是“动态导入”。我是否正确,这是指以下提案:
let module = await import('/modules/my-module.js');
Run Code Online (Sandbox Code Playgroud)
如果我们将来想使用延迟加载,有人可以预览一下路由文件实际上应该是什么样子吗?
我正在使用 Angular 8 和 NGRX 8。我有一个操作:
export const loadEnvironment = createAction(
LicencingActionTypes.LoadEnvironment,
props<{environment: Environment}>()
);
Run Code Online (Sandbox Code Playgroud)
以及相应的效果:
loadEnvironment = createEffect(() => this.actions$.pipe(
ofType(LicencingActionTypes.LoadEnvironment),
exhaustMap((action) =>
this.authService.
getToken(LicencingEffects.getAuthDetailsForEnvironment(action.environment))
.pipe(
switchMap((token) => [
AuthActions.onLogin({token: token}),
LicencingActions.onLoadEnvironment({environment: action.environment})
]),
catchError(error => of(AuthActions.onLoginError({error: error})))
)
)
));
Run Code Online (Sandbox Code Playgroud)
我一直在阅读 NGRX 8 的文档(https://ngrx.io/guide/effects#incorporating-state)。
他们的示例表明您可以只使用操作属性而不强制转换操作的类型:
...
exhaustMap(action =>
this.authService.login(action.credentials)
...
Run Code Online (Sandbox Code Playgroud)
Webpack 无法编译,并且出现以下错误:
ERROR in src/app/licencing/effects/licencing.effects.ts(20,69): error TS2339: Property 'environment' does not exist on type 'never'.
Run Code Online (Sandbox Code Playgroud)
我哪里错了?
我刚刚升级到 ngrx/store 版本 8。我注意到 ng 更新已经删除了所有 storeFreeze 的出现。也将其从metaReducer 中删除。
所以我的问题是 -为什么?
在 ngrx 8 中使用 storeFreeze 是否有问题?
在 ngrx8 之前:
import { ActionReducerMap, MetaReducer } from '@ngrx/store';
import { storeFreeze } from 'ngrx-store-freeze';
import * as fromGroupMember from './group-member.reducer';
import * as fromDirectoryForm from './directory-filter-form.reducer';
export const metaReducers: MetaReducer<IState>[] =
(localStorage && localStorage.getItem('production') === 'false') ? [storeFreeze] : [];
Run Code Online (Sandbox Code Playgroud)
后:
import { ActionReducerMap, MetaReducer } from '@ngrx/store';
import * as fromGroupMember from './group-member.reducer';
import * as fromDirectoryForm from …Run Code Online (Sandbox Code Playgroud) 我需要的
if(field.ajax && field.ajax='Y' && field.multiple&& field.multiple=='Y')
{
}
else if (field.ajax && field.ajax='Y' && field.multiple&& field.multiple=='N'))
{
}
else
{
}
Run Code Online (Sandbox Code Playgroud)
2 条件作品
if(cond)
{
code
}else
{
code
}
Run Code Online (Sandbox Code Playgroud)
这个案例代码有效
<ng-container *ngIf="field.ajax && field.ajax === 'Y'; else select2ElseBlock">
<ng-select
[items]="data"
multiple="true"
bindLabel="name"
[closeOnSelect]="true"
[loading]="loading"
[searchable]="true"
[clearable]="true"
(click)="clearModel()"
(keyup)="changed($event.target.value)">
</ng-select>
</ng-container>
<ng-template #select2ElseBlock>
<ng-select
[items]="field.choices.choice"
multiple="true"
bindLabel="name"
[loading]="loading"
>
</ng-select>
</ng-template>
Run Code Online (Sandbox Code Playgroud)
我尝试过多个案例
但这种情况会产生问题
<ng-container *ngIf="field.ajax && field.ajax === 'Y' then select2thenBlock else select2ElseBlock">
<ng-select
[items]="data"
multiple="true"
bindLabel="name"
[closeOnSelect]="true"
[loading]="loading" …Run Code Online (Sandbox Code Playgroud) 我使用以下方式进行导航:
this.router.navigateByUrl(item.url);
Run Code Online (Sandbox Code Playgroud)
item.url有价值的地方:
orgtree/1
Run Code Online (Sandbox Code Playgroud)
路线是:
{
path: "orgtree/:orgstructure",
component: OrganizationsComponent
}
Run Code Online (Sandbox Code Playgroud)
我做的内部组件:
ngOnInit() {
this.route.paramMap.subscribe(params => {
console.log(params);
});
}
Run Code Online (Sandbox Code Playgroud)
为什么我得到空参数?
我也尝试过这个:
this.router.navigate(['/orgtree', 1]);
Run Code Online (Sandbox Code Playgroud)
没有效果
我遇到问题:
路线应该是:
{
path: "orgtree",
component: OrganizationsComponent
}
Run Code Online (Sandbox Code Playgroud) 对于学校作业,我们需要使用有角度的材料。我制作了一个自定义主题,名为:weather-theme.scss
该文件中的代码如下:
\n@import '~@angular/material/theming';\n\n@include mat-core();\n\n// Define the palettes for your theme using the Material Design palettes available in palette.scss\n// (imported above). For each palette, you can optionally specify a default, lighter, and darker\n// hue. Available color palettes: https://material.io/design/color/\n$weather-theme-primary: mat-palette($mat-gray, 800, 700, 600);\n$weather-theme-accent: mat-palette($mat-amber, 800, 700);\n\n// The warn palette is optional (defaults to red).\n$weather-theme-warn: mat-palette($mat-red);\n\n// Create the theme object (a Sass map containing all of the palettes).\n$weather-theme-theme: mat-light-theme(\n $weather-theme-primary,\n $weather-theme-accent,\n $weather-theme-warn\n);\n\n// Include theme styles for core and each …Run Code Online (Sandbox Code Playgroud) 我希望在我的应用程序中实现旋转加载程序。我按照此处给出的流程[ https://www.npmjs.com/package/ngx-spinner ]安装并保存了它。
当我导入并将其添加到“导入”时,我收到以下错误。
未捕获的类型错误:Object(...) 不是 ngx-spinner.js:208 的函数,模块../node_modules/ngx-spinner/fesm5/ngx-spinner.js (ngxspinner.js:210) 在webpack_require (bootstrap ) :78) 在 Module../src/app/app.module.ts (app.component.ts:23) 在webpack_require (bootstrap:78) 在 Module../src/main.ts (main.ts:1)在webpack_require (bootstrap:78) 在 Object.0 (main.ts:12) 在webpack_require (bootstrap:78) 在 checkDeferredModules (bootstrap:45)
npm i ngx-spinner
npm install ngx-spinner --save
aap.module.ts
import { NgxSpinnerModule } from "ngx-spinner";
imports: [
// ...
NgxSpinnerModule
]
Run Code Online (Sandbox Code Playgroud)
我不知道如何摆脱这个错误如果有人可以帮助我。
我在项目中使用 ngx-material-timepicker。当我使用最新的 5.2.2 时,出现以下错误
ng:///NgxMaterialTimepickerModule/NgxMaterialTimepickerToggleComponent.n
gfactory.js:13 ERROR Error: No component factory found for NgxMaterialTimepickerContainerComponent. Did you add it to @NgModule.entryComponents?
at noComponentFactoryError (:4401/vendor.js:87649)
at CodegenComponentFactoryResolver.resolveComponentFactory (:4401/vendor.js:87714)
at DomService.appendTimepickerToBody (:4401/main-exams-exams-module.js:8424)
at NgxMaterialTimepickerComponent.open (:4401/main-exams-exams-module.js:8848)
at NgxMaterialTimepickerToggleComponent.open (:4401/main-exams-exams-module.js:8994)
at Object.eval [as handleEvent] (ng:///NgxMaterialTimepickerModule/NgxMaterialTimepickerToggleComponent.ngfactory.js:19)
at handleEvent (:4401/vendor.js:103240)
at callWithDebugContext (:4401/vendor.js:104859)
at Object.debugHandleEvent [as handleEvent] (:4401/vendor.js:104494)
at dispatchEvent (:4401/vendor.js:90327)
Run Code Online (Sandbox Code Playgroud)
但当我降级到 4.0.0 版本时,它工作得很好。
// 模块页面
import { NgModule } from '@angular/core';
import { NgxMaterialTimepickerModule } from 'ngx-material-timepicker';
@NgModule({
declarations: [appComponent ],
imports: [NgxMaterialTimepickerModule]
]
})
Run Code Online (Sandbox Code Playgroud)
html …
我刚刚迁移到 Angular 8,然后开始收到错误
Module '"../../node_modules/@angular/router/router"' has no exported member 'NoPreloading'.
Run Code Online (Sandbox Code Playgroud)
该错误来自以下行:
import { NoPreloading, RouterModule, Routes } from '@angular/router';
Run Code Online (Sandbox Code Playgroud)
它发生在 的所有成员身上@angular/router。我究竟做错了什么?尽管出现错误,一切仍然正常。
我们是否需要使用 prod 和development 构建两次项目,或者是否有其他方法可以更改指向不同服务器的 API 的根 URL,并且无需构建项目即可更改根 URL。
angular8 ×10
angular ×7
datepicker ×1
if-statement ×1
lazy-loading ×1
ngrx ×1
ngrx-effects ×1
ngrx-store ×1
sass ×1
tslint ×1
typescript ×1