我需要覆盖默认的 Angular 7 日期管道格式(medium、short、fullDate等),因为我不想使用两个日期管道(默认一个和自定义一个),所以我做了以下并想知道是一个这样做的好主意:
// extend-date.pipe.ts
import { Pipe, PipeTransform } from '@angular/core';
import { DatePipe } from '@angular/common';
@Pipe({
name: 'date'
})
export class ExtendDatePipe extends DatePipe implements PipeTransform {
constructor() {
super('en-US');
this.customDateFormats = {
medium: '...',
short: '...',
fullDate: '...',
longDate: '...',
mediumDate: '...',
shortDate: '...',
mediumTime: '...',
shortTime: '...'
};
}
transform(value: any, args?: any): any {
switch (args) {
case 'medium':
return super.transform(value, this.customDateFormats.medium);
case 'short':
return super.transform(value, this.customDateFormats.short); …Run Code Online (Sandbox Code Playgroud) Using Powershell ISE I often set breakpoints in a script and start the script from command line. ISE then stops at the breakpoint and lets me debug from there. How do I do the same from Terminal in Visual Studio Code? Below is a script just to show you what I mean. Starting from a terminal I would write:
.\hello.ps1 -firstName "firstName" -lastName "theLastName"
Run Code Online (Sandbox Code Playgroud)
But doing that from terminal it just starts a new window.
.\hello.ps1 -firstName "firstName" -lastName "theLastName"
Run Code Online (Sandbox Code Playgroud) Angular 构建生成了哪些不同的文件?我注意到其中有 6 个:
main.jspolyfill.jsruntime.jsscripts.jsvendor.jsstyles.js我想 Angular 是用来webpack构建的。但我无法找到任何可以解释这些文件包含的内容的资源。例如。main.js包含我的应用程序代码吗?如果我使用第 3 方npm软件包,它们会进入scripts.js还是vendor.js?为什么有一个.js文件styles?(我以为styles是一.css件事)。
我.eslintrc.json在 Nx/nrwl monorepo 中为 React 项目进行了配置。当我添加group到pattern属性时no-restricted-import
"rules": {
"no-restricted-imports": [
"error",
{
"patterns": [
{
"group": ["lodash/*"],
"message": "Message"
}
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
Eslint 显示错误
规则“no-restricted-imports”的配置无效:值 {"patterns":[{"group":["lodash/ "],"message":"Message"}]} 应为字符串。
值 {"patterns":[{"group":["lodash/ "],"message":"Message"}]} 不应具有其他属性。
没有group它就可以正常工作。
我镜像了此处文档中显示的相同代码
/*eslint no-restricted-imports: ["error", { patterns: [{
group: ["lodash/*"],
message: "Please use the default import from 'lodash' instead."
}]}]*/
Run Code Online (Sandbox Code Playgroud)
从“lodash/pick”导入选择;
有没有办法使以下post_filter查询有效?
我尝试过不同的方法:_score、score、doc.score、等doc._score,_source.score但没有任何效果。
我相信应该有一些解决方案可以让您按post_filter分数过滤。
{
"body": {
"post_filter": {
"script": {
"script": "_score > 100 && _score < 200"
}
},
"query": {
"function_score": {
"functions": [{
"script_score": {
"script": "doc['price'].value * 100"
}
}]
}
}
},
"index": ["items"],
"type": []
}
Run Code Online (Sandbox Code Playgroud)
ES组的类似问题:http://elasticsearch-users.115913.n3.nabble.com/Filter-on-score-td4044742.html
我正在尝试将饼图放入 Angular 组件中。我已经在一个单独的 HTML 文件中构建了这个饼图,但现在我想把这个 HTML 放到一个单页应用程序中。
<html>
<head>
<title></title>
<base href="/">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="css/dc.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" href="css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<link rel="stylesheet" href="./css/keen-dashboards.css">
<link rel="stylesheet" href="./css/bootstrap.min.css">
</head>
<body>
<!-- code to display -->
<div class="col-xs-2 pie-chart">
<h4>Cold vs Active <small><a id="day">reset</a></small></h4>
<div class="dc-chart" id="chart-ring-tier"></div>
</div>
<script src="js/d3.js"></script>
<script src="js/crossfilter.js"></script>
<script src="js/dc.js"></script>
<script src="js/jquery.dataTables.min.js"></script>
<script src='js/queue.js' type='text/javascript'></script>
<script src="node_modules/keen-dataviz/dist/keen-dataviz.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
<script type="text/javascript">
System.import('./app/app.module')
.then(null, console.error.bind(console)); …Run Code Online (Sandbox Code Playgroud) 我是 Angular 应用程序单元测试的新手,我正在尝试测试我的第一个组件。实际上,我正在尝试测试实际组件使用的抽象基类,因此我在我的规范中基于它创建了一个简单的组件,并使用它来测试它。但是有一个处理 ( Injector)依赖项,我没有正确地将它存根,因为当我尝试运行测试时,我收到此错误:
Can't resolve all parameters for TestFormInputComponentBase
但我不确定我错过了什么?这是规范:
import { GenFormInputComponentBase } from './gen-form-input-component-base';
import { Injector, Component } from '@angular/core';
import { TestBed } from '@angular/core/testing';
// We cannot test an abstract class directly so we test a simple derived component
@Component({
selector: 'test-form-input-component-base'
})
class TestFormInputComponentBase extends GenFormInputComponentBase {}
let injectorStub: Partial<Injector>;
describe('GenFormInputComponentBase', () => {
let baseClass: TestFormInputComponentBase;
let stub: Injector;
beforeEach(() => {
// stub Injector for test purpose
injectorStub = …Run Code Online (Sandbox Code Playgroud) 我正在使用这个轮播。
我想要类似这里的多项目轮播的东西。
我尝试按照本教程进行操作,但它最终破坏了我的网站并导致许多错误。
我尝试过的:
<ngb-carousel *ngIf="images">
<ng-template ngbSlide>
<div class="row">
<div class="item card col-md-3" *ngFor="let image of images">
<img src="{{image.picture}}" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
</div>
</ng-template>
</ngb-carousel>
Run Code Online (Sandbox Code Playgroud)
它没有达到我想要的效果。我想要同一行中有 2 或 3 个项目可供您滑动。您将如何使用 Angular Bootstrap Carousel 来实现这一目标?
我最后的手段是支付MDB库的费用。我们将非常感谢您的帮助。谢谢。
在我的 angular 应用程序中,我有一些功能模块:
main.module.ts (MainModule)
// imports
@NgModule({
imports: [
CommonModule,
FormsModule,
CoreModule,
MainRoutingModule,
TranslateModule.forChild(),
BsDropdownModule.forRoot(),
MainDetailModule,
MainStoreModule
],
declarations: [
// components
],
providers: []
})
export class MainModule { }
Run Code Online (Sandbox Code Playgroud)
main-detail.module.ts (MainDetailModule)
// imports
@NgModule({
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
MainDetailRoutingModule,
TranslateModule.forChild(),
MainStoreModule
],
declarations: [
// components
]
})
export class MainDetailModule { }
Run Code Online (Sandbox Code Playgroud)
main-store.module.ts (MainStoreModule)
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; …Run Code Online (Sandbox Code Playgroud) 我有以下查询,我使用“&=”逐步/动态地构建。Elasticsearch 5.x 和 Nest 5.x。
QueryContainer qfilter = null;
qfilter = Query<ClassEL>.Term(m => m.OrderID, iOrderID);
qfilter &= Query<ClassEL>
.Range(r => r
.Field(f => f.Distance)
.GreaterThan(100))
&&
.Query<ClassEL>.Term(t => t.Active, true);
var searchDes = new SearchDescriptor<ClassEL>()
.From(0)
.Size(10)
.Query(qfilter); <===== *** ERROR HERE ***
Run Code Online (Sandbox Code Playgroud)
在 Visual Studio 中,它显示以下错误消息提示:
Error: Cannot convert from 'Nest.QueryContainer' to 'System.Func<Nest.QueryContainerDescriptor<ClassEL>, Nest.QueryContainer>'
Run Code Online (Sandbox Code Playgroud)
问题是我无法让 searchDescriptor 接受我构建的查询。在线示例显示搜索+查询合并为一个,这与我想要完成的任务不同。以下是我想避免的常见示例:
var response = client.Search<Tweet>(s => s
.From(0)
.Size(10)
.Query(q =>
q.Term(t => t.User, "kimchy")
|| q.Match(mq => mq.Field(f => f.User).Query("nest")) …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的应用程序中显示模型对话框。为此,作为第一步,我将 Material Dialog 导入到我的 component.ts 文件中
import {MatDialog} from '@angular/material/dialog';
Run Code Online (Sandbox Code Playgroud)
但是在导入这个之后,我得到了这样的编译错误的音调
Error: node_modules/@angular/material/core/common-behaviors/constructor.d.ts:14:55 - error TS2304: Cannot find name 'abstract'.
14 export declare type AbstractConstructor<T = object> = abstract new (...args: any[]) => T;
~~~~~~~~
Error: node_modules/@angular/material/core/common-behaviors/constructor.d.ts:14:64 - error TS1005: ';' expected.
14 export declare type AbstractConstructor<T = object> = abstract new (...args: any[]) => T;
~~~
Error: node_modules/@angular/material/core/common-behaviors/constructor.d.ts:14:69 - error TS1109: Expression expected.
14 export declare type AbstractConstructor<T = object> = abstract new (...args: any[]) => T;
~~~
Error: …Run Code Online (Sandbox Code Playgroud) angular ×7
carousel ×1
crossfilter ×1
date-pipe ×1
dc.js ×1
debugging ×1
eslint ×1
jasmine ×1
javascript ×1
mocking ×1
nest ×1
ngrx ×1
ngrx-store ×1
nrwl-nx ×1
unit-testing ×1
webpack ×1