我以前使用的是 Angular 版本 6,现在我已经升级到 7。但是当我尝试在 CLI 中使用ng new [app-name]它创建一个新项目时,不会询问我是否要在我的项目或样式中包含路由。
PS:我有最新版本的 Angular,即 7.0.2。
我需要的初始位置cdk-virtual-scroll-viewport不是列表的第一个元素/项目。
现在我找到了scrollToIndex和scrollTo方法,但我只能在 中使用它时才能让它们工作ngAfterViewChecked,这感觉不对。
ngAfterViewChecked是正确的做事方式吗? @ViewChild(CdkVirtualScrollViewport) cdkVirtualScrollViewport: CdkVirtualScrollViewport;
numbers: number[] = [];
constructor() {
for (let index = 0; index < 10000; index++) {
this.numbers.push(index);
}
}
ngAfterViewChecked() {
this.cdkVirtualScrollViewport.scrollToIndex(2000);
}Run Code Online (Sandbox Code Playgroud)
<ul class="list">
<cdk-virtual-scroll-viewport style="height:264px" itemSize="88">
<ng-container *cdkVirtualFor="let n of numbers">
<li style="height:88px">{{ n }}</li>
</ng-container>
</cdk-virtual-scroll-viewport>
</ul>Run Code Online (Sandbox Code Playgroud)
我正在尝试为我的 Angular 7 应用程序配置用户登录,并且已经构建了大部分cognitoUser.authenticateUser()方法,但是在该onSuccess()方法中,我无法刷新 AWS 配置凭证,因为我在以下位置收到以下错误AWS.config.credentials.refresh():
“‘Credentials | CredentialsOptions’类型不存在‘refresh’属性。‘CredentialsOptions’类型不存在‘refresh’属性。”
auth.service.ts:
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import * as AWS from 'AWS-sdk';
import { CognitoIdentityCredentials } from 'AWS-sdk';
import * as AmazonCognitoIdentity from 'amazon-cognito-identity-js';
import credentials from '../../../../server/credentials.json';
@Injectable({
providedIn: 'root'
})
export class AuthService {
user: AmazonCognitoIdentity.CognitoUser;
userPool;
userData;
isAuthenticated: boolean;
constructor(private router: Router) {
const poolData = {
UserPoolId: '*****',
ClientId: credentials.appClientId
}
this.userPool = new …Run Code Online (Sandbox Code Playgroud) amazon-web-services amazon-cognito aws-lambda angular angular7
运行 npm test 时出现错误
Can't bind to 'errorStateMatcher' since it isn't a known property of 'input'. ("dth">
<input matInput placeholder="Product Name" formControlName="prod_name"
[ERROR ->][errorStateMatcher]="matcher">
Run Code Online (Sandbox Code Playgroud)
我的Spec文件如下
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { RouterTestingModule } from '@angular/router/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { ProductAddComponent } from './product-add.component';
import { FormControl, FormGroupDirective, FormBuilder, FormGroup, NgForm, Validators } from '@angular/forms';
describe('ProductAddComponent', () => {
let component: ProductAddComponent;
let fixture: ComponentFixture<ProductAddComponent>;
beforeEach(async(() => …Run Code Online (Sandbox Code Playgroud) 我有 Angular 项目,我想将其部署在 Apache 服务器上。我用ng build,但我想为后端自定义地址和端点。
proxy.conf.json:
{
"/api/*": {
"target": "http://localhost:8080",
"secure": false,
"logLevel": "debug",
"changeOrigin": true
}
}
Run Code Online (Sandbox Code Playgroud)
该配置根本不适用。我如何正确设置它以更改配置?
环境ts文件:
import {environment as prod} from './environment.prod';
export const environment = Object.assign(prod, {
production: false
});
Run Code Online (Sandbox Code Playgroud) 我有一个应用程序,它使用Angular 7作为前端,ASP.Net Core 2.2用于服务API.当我使用Google Chrome浏览器发送POST或PUT请求时,我收到ERR_INVALID_HTTP_RESPONSE错误消息.
当我将.Net Core降级到2.1版时,一切正常
此外,当我在Firefox中测试我的应用程序时,一切都运行良好!
我不知道如何解决这个问题
我使用的是谷歌Chrome版本71
当我查看Google Chrome中的"网络"标签时,我发现Chrome也向服务器发送了预检请求...
以下是"网络"标签中记录的内容:
第一:
Request URL: http://localhost:12346/api/XXXX
Request Method: OPTIONS
Status Code: 204 No Content
Remote Address: [::1]:12346
Referrer Policy: no-referrer-when-downgrade
Run Code Online (Sandbox Code Playgroud)
然后:(导致错误)
Request URL: http://localhost:12346/api/XXXX
Referrer Policy: no-referrer-when-downgrade
Run Code Online (Sandbox Code Playgroud)
如您所见,chrome不会向POST服务器发送任何请求(应该发送).
在我的产品部分有大约 300 个产品,因此对于分页我使用了 ngx-pagination 插件。所以产品应该基于媒体查询来展示。例如,我必须传递 1600px 到 1200px 的值(在媒体查询中)itemsPerPage:30,应该有 1199 到 768itemsPerPage:24
如何实现这一目标?
<ecom-section-box>
<ecom-card-wc-5 *ngFor="let data of dataArray4 | paginate: { itemsPerPage: 30, currentPage: p } " [data]="data"></ecom-card-wc-5>
</ecom-section-box>
<div class="card card2">
<span class="pagination-alignment">
<pagination-controls (pageChange)="p = $event" ></pagination-controls>
</span>
</div>
Run Code Online (Sandbox Code Playgroud) 我刚刚为工作创建了一个新的 NX 项目,并为输出接口创建了一个库,以便将它们放在后端和前端。
编译时出现此错误
apps/askeddi/src/app/pages/global-admin/global-admin.component.ts(5,38): error TS2307: Cannot find module '@eduboard/interfaces'.
Run Code Online (Sandbox Code Playgroud)
从我读到的所有内容来看,我没有做错任何事情,但它要求一个模块,它只是一个 index.ts 文件。
export * from './lib/user';
export * from './lib/global-admin-dashboard';
Run Code Online (Sandbox Code Playgroud)
这是 global-admin-dashboard
interface Schools {
total: number;
active: number;
usingAssessor: number;
}
interface TotalNActive {
total: number;
active: number;
}
export interface GlobalAdminDashboard {
schools: Schools;
schoolGroups: TotalNActive;
users: TotalNActive;
}
Run Code Online (Sandbox Code Playgroud) Sonarqube 显示 Angular 应用程序中空 css/scss 文件的错误。scss 文件为空有什么影响?它们是否会导致性能问题、副作用/错误、未来问题,复合负面问题是什么?这些通常是我们做时剩下的ng generate component
Sonarqube 标志:删除此空样式表
下面的文章指出忽略它,编译器会处理它,但是更感兴趣的是保留空文件(如果有)的效果。 空样式 (.css/.scss) 文件
公司必须在大型应用程序中检查 1000 多个空 scss 文件,有兴趣知道是否值得花时间。
我升级 ag-grid 以在 Angular 7 中使用 ag-grid 23.2.0。当我过滤页面时它可以工作。然后我离开页面,但出现了这样的错误。有人有什么主意吗?
unable to find bean reference frameworkOverrides while initialising BeanStub
Run Code Online (Sandbox Code Playgroud) angular7 ×10
angular ×9
css ×2
typescript ×2
ag-grid ×1
angular-cdk ×1
angular6 ×1
asp.net-core ×1
aws-lambda ×1
javascript ×1
lifecycle ×1
npm ×1
nrwl ×1
nrwl-nx ×1
sass ×1
sonarqube ×1