我有两个组件,一个有属性选择器.子组件是,
import { Component, OnInit, Input, ElementRef } from '@angular/core';
@Component({
selector: '[app-bar-chart]',
templateUrl: './bar-chart.component.html',
styleUrls: ['./bar-chart.component.css']
})
export class BarChartComponent implements OnInit {
@Input() chartContainer: ElementRef;
@Input() title: string;
@Input() chartData: {
title: string,
content: {
label: string,
value: number,
fill?: string
}[]
}[];
constructor() { }
ngOnInit() {
console.log(this.chartContainer);
console.log(this.chartContainer.nativeElement);
}
}
Run Code Online (Sandbox Code Playgroud)
父组件是,
import { Component, OnInit, Output, ViewChild, ElementRef } from '@angular/core';
@Component({
selector: 'app-dashboard',
template: `<div><div class="graph-image" style="width: 100%; height: 400px;" app-bar-chart [title]="barChartTitle" [chartData]="ChartData" [chartContainer]="chartContainer" #chartContainer></div></div>`, …Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中使用Angular 4.4.6反应形式和Angular Material 2.0.0-beta.12.这是我的组成部分,
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormControl, Validators } from '@angular/forms';
@Component({
selector: 'app-quick-file',
templateUrl: './quick-file.component.html',
styleUrls: ['./quick-file.component.css']
})
export class QuickFileComponent implements OnInit {
quickFileForm: FormGroup;
constructor() { }
ngOnInit() {
this.initQuickFileForm();
}
private initQuickFileForm () {
this.quickFileForm = new FormGroup({
'fileOpenDate': new FormControl(new Date(), Validators.required),
'fileSubjectEn': new FormControl(null, Validators.required),
'categoryId': new FormControl(null, Validators.required),
'subCategoryId': new FormControl(null),
'primaryClientId': new FormControl(null, Validators.required),
'primaryConsultantId': new FormControl(null, Validators.required)
});
}
saveQuickFileForm() {
console.log(this.quickFileForm);
this.quickFileForm.reset(); …Run Code Online (Sandbox Code Playgroud) 我正在使用 $.getScript 加载 ckeditor.js 文件,并在回调中启动 CKEditor。但它显示了一个错误 TypeError: c[a] is undefined。这是我的代码。我该如何解决这个问题?
$.getScript("ckeditor.js", function (data, textStatus, jqxhr) {
if (textStatus == 'success' && jqxhr.status == 200) {
CKEDITOR.replace( 'commentBox',
{
toolbar :
[
{ name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
{ name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Blockquote'] },
{ name: 'insert', items : [ 'Table','HorizontalRule','SpecialChar' ] },
{ name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
{ name: 'colors', items : [ 'TextColor','BGColor' ] }
]
});
}
});
Run Code Online (Sandbox Code Playgroud) 我正在使用 Angular Material 5 处理 Angular 5 项目。在我的一个表单中,我必须从 Web 服务中获取下拉值。这就是我声明表单数据的方式,
formData:Observable<{
taxList: {
label: string,
Value: number
}[],
category: {
label: string,
Value: number
}[]
}>;
Run Code Online (Sandbox Code Playgroud)
在ngOnInit我获取数据如下。
this.dataService.getFormData().subscribe((data) => {
this.formData = data.content;
});
Run Code Online (Sandbox Code Playgroud)
在我的模板中,
<mat-form-field class="common-form-field">
<mat-select formControlName="taxId">
<mat-option *ngFor="let tax of (formData.taxList | async)" [value]="tax.value">
{{ tax.label }}
</mat-option>
</mat-select>
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)
我得到在控制台中的错误,Cannot read property 'taxList' of undefined以及InvalidPipeArgument: '[object Object],[object Object]' for pipe 'AsyncPipe'
什么是错误和可能的解决方案?谢谢
我在Angular 4项目中使用Angular Material 2 Autocomplete.在此示例中,如何实现自动完成值从HTTP调用加载?
任何人都可以给我一个Plunker演示吗?谢谢
我正在处理一个 Angular 5 项目。在我的项目中,我有类似元素的聊天框。我在 a 中列出评论ul,其高度固定为overflow-y: auto. 就像一个标准的聊天框,我必须显示这个可滚动的最底部ul。因此,当添加新评论时,它将出现在底部,ul我必须滚动到底部。为了实现这一目标,我绑定scrollTop的这个属性ul为scrollHeight如下,
<ul class="comment-list" #commentEl [scrollTop]="commentEl.scrollHeight">
<li *ngFor="let comment of comments">{{ comment }}</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: '851'. Current value: '0'初始化此组件并销毁此组件时出现错误。我该如何解决这个问题?
我们如何使用Angular 6动画创建摇动动画?该动画应看起来像是“摇动”动画Animate.css