我试图将多个传递ng-template给我的可重用component(我的表组件),内容投影。现在我需要获取每个传递的参考值,ng-template以便我可以使用该值来知道为哪一列传递了哪个模板。基本上,我正在创建一个可重用的表组件(在 Angular 材料表之上),用户可以在其中为每列传递一个单独的模板。
请建议 - 或者有没有更好的方法来做到这一点?
temp.component.ts
import { Component, OnInit, ContentChildren, QueryList, TemplateRef, AfterContentInit } from '@angular/core';
@Component({
selector: 'my-table',
template: `<h1>This is the temp component</h1>`,
styleUrls: ['./temp.component.scss']
})
export class TempComponent implements OnInit, AfterContentInit {
constructor() { }
@ContentChildren(TemplateRef) tempList: QueryList<TemplateRef<any>>;
ngOnInit() {
}
ngAfterContentInit() {
console.log('template list');
console.log(this.tempList);
}
}
Run Code Online (Sandbox Code Playgroud)
应用程序组件.html
<my-table>
<ng-template #column1 let-company let-func="func">
<h1>this template is for column 1</h1>
</ng-template>
<ng-template #column2 let-company let-func="func">
<h1>this template is for …Run Code Online (Sandbox Code Playgroud) 我正在使用Karma和Jasmine来测试我的Angular JS代码.我设法使用Karma在我的项目中运行所有测试,但如果我尝试只运行一个文件,我会收到以下错误:ReferenceError: describe is not defined.是否可以只运行一个测试文件,如果是,那么如何?
PS我正在使用Intellij IDEA.
我使用Liquibase更改日志向现有表添加了一列,并将可为空约束设置为 true。
代码:
<changeSet id="10" author="000000">
<addColumn tableName="NCV_ATTRIBUTE">
<column name="AlternativeListPrice" type="double" defaultValue="0.0">
<constraints nullable="true"/>
</column>
</addColumn>
</changeSet>
Run Code Online (Sandbox Code Playgroud)
我想在 changeSet 11 中将可空约束从 true 更改为 false。实现此目的的最简单方法是什么?
谢谢。
我正在尝试实现通配符模块,我似乎没有得到它的工作:
现在我有以下代码可行:
typings.d.ts
declare module "*.json" {
const value: any;
export default value;
}
Run Code Online (Sandbox Code Playgroud)
app.component.ts
import { Component, OnInit } from '@angular/core';
import * as es from './i18n/es.json';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent implements OnInit {
hello = '-';
ngOnInit() {
this.hello = es.default.hello;
}
}
Run Code Online (Sandbox Code Playgroud)
您可能会看到一个活生生的例子在这里,但是我想实现通配符,因为看到这里(typescriptlang)和这里(SitePen接触):

实现应该允许我做这样的事情:
typings.d.ts
declare module "*.json!i18n" {
const value: any;
export default value;
}
declare module "*.json!static" { …Run Code Online (Sandbox Code Playgroud) 我要求在数据表之外发生更改/事件时替换所有列。
数据表第一次显示选定的列(来自事件)。如果我选择第二个,它不会显示,但 dtOptions 中的列会发生变化,但不会显示。我想清除视图问题,但我尝试使用销毁它对我不起作用。有人请帮助我实现这一目标。
HTML代码:
<div id="data-table-grid-slide">
<table datatable [dtOptions]="dtOptions" [dtTrigger]="dtTrigger" class="row-border hover"></table>
</div>
Run Code Online (Sandbox Code Playgroud)
数据表的角度代码:
import {Component, ViewChild, OnInit, Input, AfterViewInit, OnDestroy, Output, EventEmitter} from '@angular/core';
import { DataTableDirective } from 'angular-datatables';
import { Subject } from 'rxjs';
import { ColumnObject } from '../data-tables-net/model/data-tables-model';
import { HttpClient } from '@angular/common/http';
import { DtServiceService} from '../data-tables-net/dt-service.service';
import { WindowRef} from '../services/WindowRef';
declare var $;
@Component({
selector: 'app-data-tables-net',
templateUrl: './data-tables-net.component.html',
styleUrls: ['./data-tables-net.component.css']
})
export class DataTablesNetComponent implements OnInit, AfterViewInit, OnDestroy {
@ViewChild('dataTable', …Run Code Online (Sandbox Code Playgroud) 我的所有控件都使用有角度的材料。我们需要禁用自动完成功能,以便以前输入的任何值都不会显示。我的代码如下。我尝试了自动完成“关闭”“禁用”以及我在网上找到的其他建议。但似乎没有任何作用。
<mat-form-field
[ngClass]="{ 'invalid-uinque-id': (form.errors.locatorId || form.errors.locatorIdInvalidBadge) }"
id="sta_BadgeFormField"
>
<input
formControlName="locatorId"
(blur)="onBlurLocatorVendorMethod(selectedVendor.id)"
matInput
i18n-placeholder="Locator Badge ID|Placeholder for locator badge id label in add staff dialog@@addstaffLocatorBadgeId"
placeholder="Locator Badge ID"
name="locatorId"
maxlength="20"
[errorStateMatcher]="esMatcher"
autocomplete="disabled"
/>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud) 现在可以使用 来获得非平面的项目结构ng build,而不是这样:
index.html
main.bundle.js
styles.bundle.js
...
Run Code Online (Sandbox Code Playgroud)
我希望脚本位于子文件夹中
index.html
scripts/main.bundle.js
scripts/styles.bundle.js
...
Run Code Online (Sandbox Code Playgroud)
我找到了一个关于此的主题:“ng build”将脚本移动到子文件夹但租用解决方案是eject从cli进入项目webpack但Angular 7此不再可用,ng eject现在已禁用:
'eject' 命令已被禁用,将在 8.0 中完全删除。新的配置格式提供了更大的灵活性,无需弹出即可修改工作区的配置。
有几个项目可以与新的配置格式结合使用,提供弹出的好处而无需维护开销。一个这样的项目是 ngx-build-plus 在这里找到:https : //github.com/manfredsteyer/ngx-build-plus
Angular 提供的angular.json文件租用文档非常差https://github.com/angular/angular-cli/wiki/angular-workspace因此很难在实际项目问题中使用此配置文件。
我正在使用休眠/JPA。
当我执行entity.save()or 时session.update(entity),hibernate 会生成这样的查询:-
update TABLE1 set COL_1=? , COL_2=? , COL_3=? where COL_PK=?
Run Code Online (Sandbox Code Playgroud)
我可以通过实体中的任何注释在 WHERE 子句中包含一个附加列,因此它可以导致如下查询:-
update TABLE1 set COL_1=? , COL_2=? , COL_3=? where COL_PK=? **AND COL_3=?**
Run Code Online (Sandbox Code Playgroud)
这是因为我们的数据库是基于分片的COL_3,这需要出现在 where 子句中
我希望能够仅使用session.update(entity)or来实现这一点entity.save()。
e2e我在使用构建器构建应用程序时遇到运行问题@nrwl/cypress,我不太清楚。
我正在使用一个适合angular-devkit构建器的组件库,但是在使用时@nrwl/cypress,webpack 似乎尝试从相对路径而不是项目根目录加载这些组件。
因此,登陆页面上的任何组件都可以正常加载,但是当我导航到不同的路线时,该路线将用作应用程序基础,并且我的组件无法加载。
我不能肯定地说这是 的问题@nrwl/cypress,只是构建器不会发生这种情况angular-devkit。
一些配置:
"myapp-e2e": {
"root": "apps/myapp-e2e",
"sourceRoot": "apps/myapp-e2e/src",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@nrwl/cypress:cypress",
"options": {
"cypressConfig": "apps/myapp-e2e/cypress.json",
"tsConfig": "apps/myapp-e2e/tsconfig.e2e.json",
"devServerTarget": "myapp:serve"
},
"configuration": {
"production": {
"devServerTarget": "myapp:serve:production"
}
}
},
"lint": {
"builder": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": ["apps/myapp-e2e/**/*.{js,ts}"]
}
}
},
"tags": [],
"implicitDependencies": ["myapp"]
},
Run Code Online (Sandbox Code Playgroud)
赛普拉斯.json
{
"fileServerFolder": ".",
"fixturesFolder": "./src/fixtures",
"integrationFolder": "./src/integration",
"modifyObstructiveCode": false,
"pluginsFile": "./src/plugins/index",
"supportFile": "./src/support/index.ts", …Run Code Online (Sandbox Code Playgroud) 在使用最新版本的 Angular(版本 14)时,我似乎没有做得很好,因此严格类型化的反应式表单无法按预期工作。
表单是ngOnInit使用injected在内部初始化的FormBuilder。
public form!: FormGroup;
constructor(private formBuilder: FormBuilder) {}
ngOnInit(): void {
this.initializeForm();
}
private initializeForm(): void {
this.form = this.formBuilder.group({
title: ['', [Validators.required, Validators.minLength(3)]],
content: ['', Validators.required],
});
}
Run Code Online (Sandbox Code Playgroud)
现在,当我尝试访问表单的控件时,没有自动完成功能,类型为FormGroup<any>。此外,当尝试访问对象上不存在的控件时,它不会引发错误FormGroup。
package.jsonangular ×6
typescript ×3
forms ×2
javascript ×2
angular-cli ×1
angular14 ×1
angular6 ×1
angular7 ×1
angularjs ×1
autocomplete ×1
autofill ×1
cypress ×1
database ×1
datatable ×1
hibernate ×1
html ×1
jasmine ×1
karma-runner ×1
liquibase ×1
mysql ×1
nrwl-nx ×1
sharding ×1
spring-data ×1