小编uru*_*ruk的帖子

Angular SSR:构建错误 TS6306:引用的项目必须具有设置“composite”:true

我正在使用 SSR 开发 Angular 应用程序,但在使用 构建时出现以下错误npm run build:ssr

ERROR in [...]/tsconfig.json
[tsl] ERROR
      TS6306: Referenced project '[...]/tsconfig.app.json' must have setting "composite": true.

ERROR in [...]/tsconfig.json
[tsl] ERROR
      TS6306: Referenced project '[...]/tsconfig.server.json' must have setting "composite": true.
Run Code Online (Sandbox Code Playgroud)

然后我尝试将此密钥添加到tsconfig.app.jsonand tsconfig.server.json,但我不确定在哪里添加此密钥:

tsconfig.app.json(以及相应的 tsconfig.server.json)

{
    "extends": "./tsconfig.base.json",
    "compilerOptions": {
        "outDir": "./out-tsc/app",
        "types": [],
        "composite": true   // <-- generates the next error (see below)
    },
    "files": [
        "src/main.ts",
        "src/polyfills.ts"
    ],
    "include": [
        "src/**/*.d.ts"
    ],
    "exclude": [
        "src/test.ts",
        "src/**/*.spec.ts"
    ],
    "composite": …
Run Code Online (Sandbox Code Playgroud)

typescript server-side-rendering angular

14
推荐指数
1
解决办法
2万
查看次数

即使未在 - (NSUInteger)supportedInterfaceOrientations中定义,也检测UIViewController上的接口旋转

我有一个UIViewController在主视图上处理几个UIImageViews.在底部是一个UIToolbar,其中有几个项目可以与之交互.

现在,当我旋转设备时,我不希望viewController旋转,而只是UIImageViews.换句话说,底部的工具栏将位于左侧(或右侧),但imageViews将正确旋转.

所以,通过使用方法

- (BOOL)shouldAutoRotate {
   return YES;
}
Run Code Online (Sandbox Code Playgroud)

结合

- (NSUInteger)supportedInterfaceOrientations {
   return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
// rotate the image views here
}
Run Code Online (Sandbox Code Playgroud)

设备上的任何旋转都不会被执行,因为只支持一个接口方向(UIInterfaceOrientationMaskPortrait).但是当我在supportedInterfaceOrientations-method中添加另一个支持的接口方向时,视图控制器也会旋转.

即使只支持一个方向,如何检测视图控制器的旋转?或者是否有另一种可能性根据不断变化的设备方向旋转UIViews?

谢谢你的帮助!

ios6

6
推荐指数
1
解决办法
4077
查看次数

如何在Angular i18n路由器模块中使用LOCALE_ID

我用Angular的i18n设置构建了一个小的Angular应用程序。一切正常,除了url路径和段的翻译。我尝试了一种可能的解决方案,即按每种语言提供路由模块(如此处所述),但这没有用。

我以为我可以做以下事情,但是我不知道要在哪里注射LOCALE_ID

app-routing.module.ts

import { LOCALE_ID, NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { MainComponent } from './main/main.component';

const i18nRoutes = {
    de: {
        main: 'inhalte',
        // ...
    }, 
    fr: {
        main: 'contenu',
        // ...
    }
}

const currentLanguage = i18nRoutes[ LOCALE_ID ]; // <-- Apparently not working, since I have to inject LOCALE_ID. But where?

const routes: Routes = [
    {
        path: '',
        redirectTo: currentLanguage.main,
        pathMatch: 'full'
    },
    {
        path: currentLanguage.main + …
Run Code Online (Sandbox Code Playgroud)

routing internationalization angular

5
推荐指数
2
解决办法
4999
查看次数

Angular 的 @HostBinding( 'window:resize' ) 和 Rxjs' fromEvent( window, 'resize' ) 之间的区别

我只是想知道使用其中一种而不是另一种有什么优势。

\n
@HostListener( 'window:resize' )\ndoSomething(): void {\n    // ...throttle with setTimeout and clearTimeout maybe...\n}\n
Run Code Online (Sandbox Code Playgroud)\n

\n
fromEvent( window, 'resize' ).pipe(\n    // ... debounceTime, takeUntil etc.\n).subscribe( () => {\n    doSomething();\n})\n
Run Code Online (Sandbox Code Playgroud)\n

这真的只是一个上下文问题(例如,使用 pipeline() 更容易处理事件流),还是可观察的更多 \xc2\xabmordern\xc2\xbb ,或者根本不重要?

\n

谢谢!

\n

settimeout observable angular

2
推荐指数
1
解决办法
1725
查看次数