我正在尝试从 S3 下载 .jpg 和 .pdf 图像,其具有以下设置
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
Run Code Online (Sandbox Code Playgroud)
按照类似于(How do I download a file with Angular2)的方法,在 Firefox 中一切正常。在 Chrome 中,PDF 下载工作正常,但当我尝试下载图像时,总是收到 GET 请求的典型 CORS 错误。
downloadFile(url, type, fileName) {
this.http.getFile(url, { responseType: 'blob' }).
subscribe(data => this.downloadFileComplete(data, type, fileName));
}
downloadFileComplete(data: any, type: string, fileName: string) {
let fileType = (type === 'IMAGE') ? 'image/jpeg' : 'application/pdf';
var blob = new Blob([data], { type: fileType.toString() });
if (type …Run Code Online (Sandbox Code Playgroud) 我们正在使用 Angular 的内置工具从模板中提取消息。
这工作正常,我们使用以下命令获取 XLIFF 文件中的所有信息:
ng xi18n
Run Code Online (Sandbox Code Playgroud)
在这个文件中,atrans-unit看起来像这样:
<trans-unit id="3535a6c8296b457542000d2cbd15ca93f86cdd79" datatype="html">
<source>Homepage</source>
<context-group purpose="location">
<context context-type="sourcefile">app/component/nav/nav.component.html</context>
<context context-type="linenumber">39</context>
</context-group>
<note priority="1" from="description">description</note>
<note priority="1" from="meaning">title</note>
</trans-unit>
Run Code Online (Sandbox Code Playgroud)
尽管其中的内容<context-group purpose="location">看起来很有趣,但它向外部翻译服务解释了项目和实施细节。
有没有办法告诉 Angular 不要将这些信息包含到 XLIFF 文件中?
或者,是否有其他工具可以进行转换?也许编译器在构建过程中获得这些信息很重要。
我读了一些文章似乎无法实现延迟加载我的应用程序。我安装了 angular 8,似乎我有正确的语法。是否有特定的策略或方法需要组织我的组件以使延迟加载工作?
这是错误消息:
core.js:7187 ERROR Error: Uncaught (in promise): Error: ASSERTION ERROR: NgModule 'MyReportsGridComponent' is not a subtype of 'NgModuleType'.
Error: ASSERTION ERROR: NgModule 'MyReportsGridComponent' is not a subtype of 'NgModuleType'.
Run Code Online (Sandbox Code Playgroud)
在我的 app.routing.module.ts 中,我有什么:
const routes: Routes = [
{path: '', component:LoginComponent},
{path: 'Login', component:LoginComponent},
{path: 'tasks', component:TaskComponent, canActivate:[AuthGuard]},
{path: 'CreateTask', loadChildren: () => import ('./create-task/create-task.component').then(m => m.CreateTaskComponent), canActivate:[AuthGuard]},
{path: 'ManageUser', loadChildren: () => import ('./manage-users/manage-users.component').then(m => m.ManageUsersComponent), canActivate:[AuthGuard]},
{path: 'MyReports', loadChildren: () => import ('./my-reports-grid/my-reports-grid.component').then(m => m.MyReportsGridComponent), canActivate:[AuthGuard]}, …Run Code Online (Sandbox Code Playgroud) 我在使用 ngx-translate-messageformat-compiler 插件时遇到问题(添加复数形式后 json 文件解析失败)。\xc2\xbf还有其他选择吗?
\n使用此资源,我想在多个嵌套级别上实现 formControlName。
Angular 2 - 组件内的 formControlName
假设实际的 formGroup 比子 formControlName 组件高 3 个组件级别,
如果父组件紧挨着子组件,则 ControlValueAccessor 起作用。然而,以上(祖父)形式的多个级别不起作用。
是否有服务或多个输入/输出的替代方案?或者这些是唯一的方法?
A--> Component with formGroup
B---> Component container
C---> Component container
D ---> Component with FormControlName (should pass to Component A)
Run Code Online (Sandbox Code Playgroud)
组件A会从类似的不同子组件中收集多个表单控件名称,
输入文本.ts
export class InputTextComponent implements AfterViewInit, ControlValueAccessor {
@Input() disabled: boolean;
@Output() saveValue = new EventEmitter();
value: string;
onChange: () => void;
onTouched: () => void;
writeValue(value: any) {
this.value = value ? value : "";
}
registerOnChange(fn: any) {this.onChange = …Run Code Online (Sandbox Code Playgroud) LazyLoading chunkName 未显示
const webpack = require('webpack');
const path = require('path');
var PROD = JSON.parse(process.env.PROD_ENV || '0');
module.exports = {
entry: {
clientApp: "./App/Modules/main",
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: "[name].bundle.js",
chunkFilename: '[name]-[chunkhash].js',
publicPath: '/dist/',
},
resolve: {
extensions: ['.js']
},
module: {
loaders: [
'angular-router-loader'
]
},
plugins: [
]
}
Run Code Online (Sandbox Code Playgroud)
{
path: 'about',
loadChildren: () => import('../Features/about/about.module').then(m => m.AboutModule)
}
Run Code Online (Sandbox Code Playgroud)
它不显示块的模块名称。我在这里做错了什么?
我正在为我的项目使用 Angular 8,使用节点版本 10.15.3(曾尝试使用其他版本,包括最新的 12.31.1)。这在 MAC 上工作正常,但在 Windows 上运行时,它在浏览器上停止并出现错误
NullInjectorError: "StaticInjectorError(AppModule)[MatCommonModule -> HighContrastModeDetector]:
StaticInjectorError(Platform: core)[MatCommonModule -> HighContrastModeDetector]:
NullInjectorError: No provider for HighContrastModeDetector!"
Run Code Online (Sandbox Code Playgroud)
这是否与我的硬件有关(它是如何相关的)?
我正在使用 Angular8 和反应式形式。我的 ngOnInit 是:
ngOnInit(): void {
this.makeForm = this.fb.group(
year: ['', Validators.required],
amount: ['', Validators.required],
desc: ['', Validators.required],
details: new FormArray([
this.det(),
]
);
}
det() {
return new FormGroup({
for: new FormControl(''),
remarks: new FormControl('')
});
}
Run Code Online (Sandbox Code Playgroud)
我有来自后端的数据来修补数组:
{
"amount": 9000,
"year": 1996,
"id": 1,
"desc": "P1",
"details": [
{
"id": 1,
"remarks": "ok",
"for": "1"
},
{
"id": 24,
"remarks": "OK",
"for": "1"
},
{
"id": 25,
"remarks": "OK",
"for": "1"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我通常用这种方法修补值:
getppredit() …Run Code Online (Sandbox Code Playgroud) angular-material angular angular-reactive-forms angular-forms angular8
我的 Angular 12 应用程序中有一些通用组件,我计划将其创建为 Angular 库,以便其他应用程序也可以使用它。我们有一些应用程序在较低版本的 Angular(例如 Angular 8 / Angular 10)上运行,它们也将使用这个通用库。
\n我已经在 Angular 12 中创建了库,它在 Angular 12 应用程序中运行良好。但是,它在使用 Angular 8 和 Angular 10 的其他应用程序中不起作用。
\n出现如下错误:
\nfesm2015/common-lib.js 12:145-163 "export '\xc9\xb5\xc9\xb5FactoryTarget' (imported as 'i0') was not found in '@angular/core'\nRun Code Online (Sandbox Code Playgroud)\n所以,主要的困惑是我是否需要为 v8、v8 和 v12 应用程序创建 3 个不同的角度库。或者有什么方法可以创建一个可供所有 3 个角度应用程序使用的库(版本 8/10/12)。
\n请建议正确的继续方式。
\n父组件
<form [formGroup]="User">
<app-radioButton [group]="user"></app-radiobuton>
</form>
Run Code Online (Sandbox Code Playgroud)
在无线电组件 html 中
<mat-radio-button [formControlName]="name" > <mat-radio-button>
Run Code Online (Sandbox Code Playgroud)
无线电组件的 .ts 中
export class RadioComponent{
@Input() group: FormGroup;
}
Run Code Online (Sandbox Code Playgroud)
报错如上。不知道我做错了什么。