如何从延迟加载的模块访问 AppModule 导入?
我的Angular10应用程序将AngularMaterial 和 NXTranslate 模块导入到 AppModule 中。NxTranslate 调用 ApiService 来获取包含数千个翻译的大型 Lookup 对象。这是在 AppModule 的初始加载时转换的。
该应用程序有多个延迟加载的路由,它们也需要在其功能中使用 AnagularMaterial 和 NXTranslate 模块。
如果我使用SharedModule 加载模块,则多次调用 ApiService。这显然不好。它应该只调用一次 ApiService 和 AngularMaterial 并且可用于所有模块。
我该如何解决?我在挣扎。谢谢。
更新 (对不起,这篇文章太长了)这是NXTranslate实现 - 它使用自定义类。
import { environment } from './../../../../environments/environment';
import { OSCITranslateService } from './translate.service';
import { NgModule, Injector } from '@angular/core';
import { CommonModule } from '@angular/common';
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
import {HttpClient, HttpClientModule} from '@angular/common/http'; …Run Code Online (Sandbox Code Playgroud) 有谁知道如何使用 StoryBook 和 Angular 与 NGRX Store 或有链接吗?
我已遵循 StoryBook 教程,但仍然无法弄清楚如何将 StoryBook 与 NGRX Store 一起使用。我可以很好地使用 StoryBook 和 Angular Dumb 组件。我需要能够为嵌套组件的故事设置 NGRX 存储状态。
例如。在我的SmartComponent中,我有:
this.accountDebtor$ = this.coreStore.select( coreSelector.selectAccountDebtorState );
在故事中我有:
export const LoadedAccountPanel = (args) => ({
component: AccountComponent,
props: args,
});
LoadedAccountPanel.args = {
panelData: {},
accountDebtor$: <-- How do I set the State so this gets set using the store ???,
};
Run Code Online (Sandbox Code Playgroud) 我一直在尝试使用 AngularJs 指令和控制器在单击时动态设置两种颜色之间的背景动画(到目前为止尚未成功)。
有谁知道如何做到这一点?我一直在尝试存储 currCol (存储为数组 var 推入 ng-class),但后来我无法从 ng-class 检索该值并使用它。
我已将 css 从透明转换为颜色,但我无法弄清楚如何在两个动态颜色变量之间进行转换。任何帮助都会很棒。谢谢。
到目前为止的一些代码:
索引.html
<body ng-app="colourTest">
<div ng-controller="BgCtrl" >
<ion-nav-bar id="bgCont" data-mylo-color="" ng-class="colorVal" animate-On-Change="colorVal" ></ion-nav-bar>
<ion-nav-view animation="slide-left-right">
<button ng-click="test3()">set bg</button>
</ion-nav-view>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
控制器.js
.controller('BgCtrl', ['$scope', function ($scope) {
$scope.colorPane = 'whiteBg';
$scope.colorVal = '';
var colCount = 0;
var colorArr = ['redBg', 'greenBg', 'blueBg', 'whiteBg'];
var currColor = '';
$scope.test3 = function () {
if (colCount < colorArr.length)
{
$scope.colorVal = colorArr[colCount];
colCount ++;
} else { …Run Code Online (Sandbox Code Playgroud) angular ×2
javascript ×2
angularjs ×1
colors ×1
directive ×1
lazy-loading ×1
module ×1
ngrx ×1
ngrx-store ×1
storybook ×1