我已经使用rxjs-lint包和以下命令使用新的管道方法更新了Angular 5.5/rxJS5.5以及Angular 6/rxJS6的代码
npm i -g rxjs-tslint
rxjs-5-to-6-migrate -p tsconfig.json
Run Code Online (Sandbox Code Playgroud)
进口等已经按预期进行了修改,但是现在使用RxJS的Angular/5.5的v5工作正常的代码错误的错误:
error TS2339: Property 'pipe' does not exist on type 'OperatorFunction<{}, {} | RouterEvent | RouteConfigLoadStart | RouteConfigLoadEnd | ChildActivati...'.
Run Code Online (Sandbox Code Playgroud)
我删除了rxjs6-compat包,但没有区别.这几乎就像构建认为它有一个早于rxJS的版本而不是v5.5. 与npm install一起使用的package.json看起来像这样......
"dependencies": {
"@angular/animations": "^6.0.2",
"@angular/cdk": "^6.0.2",
"@angular/common": "^6.0.2",
"@angular/compiler": "^6.0.2",
"@angular/core": "^6.0.2",
"@angular/flex-layout": "^6.0.0-beta.15",
"@angular/forms": "^6.0.2",
"@angular/http": "^6.0.2",
"@angular/material": "^6.0.2",
"@angular/platform-browser": "^6.0.2",
"@angular/platform-browser-dynamic": "^6.0.2",
"@angular/router": "^6.0.2",
"@ngrx/effects": "^6.0.0-beta.3",
"@ngrx/entity": "^6.0.0-beta.3",
"@ngrx/router-store": "^6.0.0-beta.3",
"@ngrx/store": "^6.0.0-beta.3",
"@ngrx/store-devtools": "^6.0.0-beta.3",
"@ngx-translate/core": "^9.0.1",
"core-js": "^2.5.2",
"hammerjs": "^2.0.8",
"lodash": …Run Code Online (Sandbox Code Playgroud) 我完全对此错误感到困惑。我有一个非常基本的简单路由:
const routes: Routes = [
{
path: '', component: FrameDefaultComponent, pathMatch: 'full',
children: [
{path: '', component: SiteCalculatorComponent},
{path: 'site-notice', component: SiteSiteNoticeComponent}
]
},
];
Run Code Online (Sandbox Code Playgroud)
当我单击菜单菜单项中的site-notice时,如下所示:
menuEntries = [
{
title: 'Calculator',
url: '/'
},
{
title: 'Site Notice',
url: '/site-notice'
}
];
Run Code Online (Sandbox Code Playgroud)
然后我得到以下错误:
core.js:1521 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'site-notice'
Error: Cannot match any routes. URL Segment: 'site-notice'
at ApplyRedirects.push../node_modules/@angular/router/fesm5/router.js.ApplyRedirects.noMatchError (router.js:1359)
at CatchSubscriber.selector (router.js:1340)
at CatchSubscriber.push../node_modules/rxjs/_esm5/internal/operators/catchError.js.CatchSubscriber.error (catchError.js:33)
at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:80)
at …Run Code Online (Sandbox Code Playgroud) 我正在使用Angular 6和Angular Material.我试图从mat-chip和自动完成中保存所选对象或所选对象列表.我能够将字符串值发送到fruits []数组,但无法将所选对象发送到fruits []数组.请帮我找一个解决方案.谢谢.
我的演示项目链接:stackblitz上的演示代码
angular-material md-chip mat-autocomplete angular6 angular-material-6
我在尝试使Bootstrap 4复选框与全选并取消选择6+中的所有选项时遇到问题。当我在此处使用原始代码时,它可以正常工作:http :
//www.angulartutorial.net/2017/04/select-all-deselect-all-checkbox.html
但问题是Bootstrap使用其他事件单击他们的复选框。有人对此有解决方案吗?
<div class="form-check">
<input class="form-check-input" type="checkbox" (change)="selectAll()">
<label class="form-check-label">
Select All
</label>
</div>
<div class="form-check" *ngFor="let n of names">
<input class="form-check-input" type="checkbox" value="{{n.name}}" [(ngModel)]="selectedNames" (change)="checkIfAllSelected()">
<label class="form-check-label">
{{n.name}}
</label>
</div>
Run Code Online (Sandbox Code Playgroud)
和TS:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-checkbox',
templateUrl: './checkbox.component.html',
styleUrls: ['./checkbox.component.scss']
})
export class CheckboxComponent implements OnInit {
title = 'Checkbox';
names: any;
selectedAll: any;
constructor() {
this.title = "Select all/Deselect all checkbox - Angular 2";
this.names = [
{ name: …Run Code Online (Sandbox Code Playgroud) 我正在为项目使用角材料的树组件。这是 stackblitz链接,在这里我需要实现两件事:
1)子元素的文本颜色必须在鼠标悬停时更改。
2)在单击/选择子元素时,必须更改背景颜色,背景颜色必须保持不变,直到我选择下一个子元素(如带有选择的列表)为止。
像这样
在我的应用程序从Angular 4 ^迁移到Angular 6(最新版本)后,我的Auth服务中出现了一个非常奇怪的错误.
具体而言,angular2,智威汤逊,当我尝试包导致一个杀手错误"serve"或"build"在应用production环境.另一方面,相同的代码在"dev"环境中运行得非常好.
操作系统 - > MacOS 10.13.6
执行时遇到的错误ng serve --configuration production:
ERROR in : Error: Internal error: unknown identifier [{"filePath":"/Users/paulo/Projects/eleo-usuario/node_modules/angular2-jwt/angular2-jwt.d.ts","name":"AuthHttp","members":[]},{"filePath":"/Users/paulo/Projects/eleo-usuario/node_modules/@angular/common/common.d.ts","name":"LocationStrategy","members":[]}]
at Object.importExpr$$1 [as importExpr] (/Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler/bundles/compiler.umd.js:21757:27)
at tokenExpr (/Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler/bundles/compiler.umd.js:11810:43)
at providerDef (/Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler/bundles/compiler.umd.js:11736:24)
at /Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler/bundles/compiler.umd.js:11906:81
at Array.map (<anonymous>)
at NgModuleCompiler.compile (/Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler/bundles/compiler.umd.js:11906:48)
at AotCompiler._compileModule (/Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler/bundles/compiler.umd.js:21702:36)
at /Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler/bundles/compiler.umd.js:21621:70
at Array.forEach (<anonymous>)
at AotCompiler._compileImplFile (/Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler/bundles/compiler.umd.js:21621:23)
at /Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler/bundles/compiler.umd.js:21611:74
at Array.map (<anonymous>)
at AotCompiler.emitAllImpls (/Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler/bundles/compiler.umd.js:21611:39)
at AngularCompilerProgram.generateFilesForEmit (/Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler-cli/src/transformers/program.js:736:46)
at AngularCompilerProgram._emitRender2 (/Users/paulo/Projects/eleo-usuario/node_modules/@angular/compiler-cli/src/transformers/program.js:330:27)
at …Run Code Online (Sandbox Code Playgroud) 我将在我的angular6项目中安装jsonwebtoken模块npm i jsonwebtoken.安装了jsonwebtoken模块Dependencies jwa,但是index.js文件加密需要错误无法解析'crypto',但我已经安装了crypto模块.
请帮助并解决问题.
我的错误:
ERROR in ./node_modules/jwa/index.js
Module not found: Error: Can't resolve 'crypto' in '/opt/lampp/htdocs/angular-testing-app/node_modules/jwa'
ERROR in ./node_modules/jws/lib/sign-stream.js
Module not found: Error: Can't resolve 'stream' in '/opt/lampp/htdocs/angular-testing-app/node_modules/jws/lib'
ERROR in ./node_modules/jws/lib/verify-stream.js
Module not found: Error: Can't resolve 'stream' in '/opt/lampp/htdocs/angular-testing-app/node_modules/jws/lib'
ERROR in ./node_modules/jws/lib/data-stream.js
Module not found: Error: Can't resolve 'stream' in '/opt/lampp/htdocs/angular-testing-app/node_modules/jws/lib'
Run Code Online (Sandbox Code Playgroud) 我有以下问题。单击以检查堆栈闪电。
我在构造函数中设置了反应形式:
this.formGroup = this.fb.group({
'family_name_en': new FormControl('', Validators.required),
'family_name_ar': new FormControl('', [Validators.required, Validators.pattern('[\u0600-\u06FF ]*')]),
'unit_id': new FormControl({ value: '', disabled: true }, [Validators.required])
});
Run Code Online (Sandbox Code Playgroud)
而且ngOnInti(),我正在获取与关联的数据unit_id。
当我将数据从平台迁移到另一个平台时,不建议使用阿拉伯语的姓氏,但现在是这样。因此,大多数数据将不使用阿拉伯文名称加载。
问题是该按钮始终处于启用状态,而我需要做的是,如果用户要更新此unit_id按钮,则他应该添加阿拉伯语名称,以便随后启用该按钮。
如果表单有效,则启用按钮在加载组件时不会造成伤害。
这是getData()获取数据并设置表单组控件值的方法:
ngOnInit() {
this.getDataById();
}
Run Code Online (Sandbox Code Playgroud)
getDataById():
getDataById() {
this.showSpinner = true;
this.auth.getDataById(this.unit_id).subscribe(
(data) => {
if (data['info'][0]['total'] == 1) {
this.noDataBool = false;
this.showSpinner = false;
this.family_name_en = data['info'][0]['hh_last_name_en'];
this.formGroup.controls['family_name_en'].setValue(this.family_name_en);
this.family_name_ar = data['info'][0]['hh_last_name_ar'];
this.formGroup.controls['family_name_ar'].setValue(this.family_name_ar);
this.unit_id = data['info'][0]['unit_id'];
this.formGroup.controls['unit_id '].setValue(this.unit_id);
}
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用<p-toast>登录页面中的A在用户登录时显示通知消息。
<p-toast position="top-center" key="tc"></p-toast>
Run Code Online (Sandbox Code Playgroud)
这些消息然后在我的组件中声明。
ngOnInit() {
// add toasts
this.messageService.addAll([
{key: 'tc', severity: 'info', summary: '30 Nov 2020', detail: 'Important message 1'},
{key: 'tc', severity: 'info', summary: '30 Nov 2020', detail: 'Important message 2'}
]);
// do other stuff
}
Run Code Online (Sandbox Code Playgroud)
这行不通。为了确认我的吐司或消息没有问题,我将消息放置onClick()在页面上的一个事件中,并手动触发了该事件,该消息确实起作用。
如何获得吐司来代替页面加载?
我有这个产生的字符串:
string str = [{"id":1,"name":"Angular"},{"id":2,"name":"SpringBoot"}]
Run Code Online (Sandbox Code Playgroud)
我想将其转换为Objects数组以使其具有:
listexps: Expertise[];
listexps = [{"id":1,"name":"Angular"},{"id":2,"name":"SpringBoot"}];
Run Code Online (Sandbox Code Playgroud)
而专门知识课程是
export class Expertise
{
id: number;
name: string;
}
Run Code Online (Sandbox Code Playgroud)
我尝试过:
let array = str .replace('[{','').replace('}]','').split("},{").map(String);
Run Code Online (Sandbox Code Playgroud)
但这并不能解决我的问题,我得到了:
"id":1,"name":"Angular","id":2,"name":"SpringBoot"
Run Code Online (Sandbox Code Playgroud)
代替
[{"id":1,"name":"Angular"},{"id":2,"name":"SpringBoot"}];
Run Code Online (Sandbox Code Playgroud)
您对解决这个问题有任何想法吗?非常感谢。
angular6 ×10
angular ×6
angular2-jwt ×1
angular7 ×1
arrays ×1
bootstrap-4 ×1
html ×1
javascript ×1
json ×1
jwt ×1
md-chip ×1
primeng ×1
rxjs6 ×1
typescript ×1