我正在使用简单的日期管道来格式化日期,这在 web 和 android 浏览器上运行良好,但在 IOS 上它什么也没显示。如果我移除 PIPE 并显示数据,那么它会显示,但不会与 PIPE 一起显示。
{{race.race_date | date:'M/d/y'}}
Run Code Online (Sandbox Code Playgroud)
您可以在问题链接上检查此问题
后端正确返回数据。
我正在为 angular 应用程序运行单元测试,我想对导航在 angular 应用程序中是否正常工作进行单元测试。
if (this.customer.length == 0) {
this.router.navigate(['/nocustomer']);
}
Run Code Online (Sandbox Code Playgroud)
以及为此的单元测试
it(`should navigate to nocustomer`,()=>{
component.customers.length=0;
//what must be written here to check this
})
Run Code Online (Sandbox Code Playgroud) 当我创建 Angular 应用程序时,我使用 CLI 来生成组件。在开发应用程序一段时间后,我为每个组件都有样式文件,但其中大部分是空的。
当我检查声纳时,我在空样式文件中有代码气味:
我应该删除声纳规则还是必须删除项目中的所有空样式文件并在需要它们进行组件样式时在下一个版本的项目中重新创建它们?什么是最佳实践?
我有一个材质 UI 文本字段,其中包含一个onChange. 这onChange,就拿来event执行函数了handleOnChange。handleOnChange在当前的实现中,每次更改时都会执行该函数event。
是否可以debounce直接在 2000ms 后执行该函数event?
我的文本字段
<TextField
onChange={
event =>
handleOnChange(
event.target.value,
firstValue,
secondValue,
)
/>
Run Code Online (Sandbox Code Playgroud)
我的功能
const handleOnChange = (value, firstValue, secondValue) => {
...do something..
}
Run Code Online (Sandbox Code Playgroud)
我尝试了以下操作,但handleOnChange每次event更改时仍然会触发,而不是在 2000 毫秒后触发。
<TextField
onChange={
event =>
_.debounce(handleOnChange(
event.target.value,
firstValue,
secondValue,
), 2000)
/>
Run Code Online (Sandbox Code Playgroud) 我有一个 Angular 8 应用程序并测试在 environment.ts 文件中设置的超时。我目前已将超时设置为 6 分钟。我有两个环境文件,即 environment.ts 和 enviornment.prod.ts。我相信执行 ng build --prod 时会使用 environment.prod.ts 。
运行 ng build 命令后,我无法在分发文件夹中找到环境文件。有人可以告诉我在哪里可以找到它吗?它是在某些二进制文件中吗?
这就是我的环境文件的样子
// The file contents for the current environment will overwrite these during build.
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
// The list of which env maps to which file can be found in `.angular-cli.json`.
export const environment = …Run Code Online (Sandbox Code Playgroud) 我有 2 个文件en.json,并且xx.json有 Angular 应用程序中的翻译。常见的想法是在两个文件中为多语言应用程序创建翻译,但有时一些程序员仅在其中一个文件中添加翻译,因为他们仅用自己的语言测试应用程序。
我正在寻找能够检查两个 JSON 文件中相同结构的工具,否则它会抛出错误,并且在您为第二语言创建翻译时有助于添加。您知道这方面有什么好的做法、工具或插件吗?我正在使用网络风暴。
我尝试使用 ngx-material-timepicker ,如下面的代码,但我无法更改任何 CSS 类,我正在关注此链接https://www.npmjs.com/package/ngx-material-timepicker
这是我的代码
<div class="clock">
<input placeholder="24hr format" aria-label="24hr format" [ngxTimepicker]="fullTime" [format]="24" readonly />
<ngx-material-timepicker
[appendToInput]="true"
[disableAnimation]="true"
[theme]="oktTheme"
(timeSet)="onTimeset($event)"
#fullTime
></ngx-material-timepicker>
</div>
Run Code Online (Sandbox Code Playgroud)
这是ts代码
oktTheme = {
container: {
bodyBackgroundColor: "#424242",
buttonColor: "#fff"
},
dial: {
dialBackgroundColor: "#555"
},
clockFace: {
clockFaceBackgroundColor: "#555",
clockHandColor: "#01806b",
clockFaceTimeInactiveColor: "#fff"
}
};
Run Code Online (Sandbox Code Playgroud) 当我尝试在终端中运行它时,某种程度上缺少SCSS的选项.在为AngularJs 7生成新项目期间,如何获取SCSS选项?
我在Angular 6中做了一个Web应用程序.我从Firebase接收了一组对象,我正在尝试向用户显示详细信息ngFor.我的对象数组是这样的:
export interface Competition {
createdAt: Date;
sessions: Session[];
}
export interface Session {
date: Date;
program: Program[];
events: Event[];
}
export interface Program {
name: string;
}
export interface Event {
name: string;
}
Run Code Online (Sandbox Code Playgroud)
在我正在做的模板内:
<ng-container *ngFor="let competition of competitions; index as i">
<h3>{{competition.name}}</h3>
{{competition.sessions[i].program.length}}
{{competition.sessions[i].events.length}}
</ng-container>
Run Code Online (Sandbox Code Playgroud)
读取未定义的属性"program",读取未定义的属性"events"
我试过了:
{{competition[i].sessions[i].program.length}}
{{competition.sessions[i].program.length}}
{{competition[i].sessions[i].program[i].length}}
Run Code Online (Sandbox Code Playgroud)
我的目标是显示的长度program和events.
全部,
我很难让 FormArray 与我当前的应用程序一起工作。我正在尝试从服务中获取姓名并将其添加到预订表单中(并赋予用户添加/删除/修改姓名的能力)
这是相关代码:
reservationForm: FormGroup;
attendeeArray: FormArray;
constructor(
private groupMeetingService: GroupMeetingsService,
private formBuilder: FormBuilder
) {}
ngOnInit() {
this.initialize();
}
private createAttendeeName(name: string): FormControl {
return this.formBuilder.control({
name: name
});
}
private initialize(): void {
this.attendeeArray = this.formBuilder.array([]);
this.reservationForm = this.formBuilder.group({
attendeeRadio: ['inPerson'],
attendeeName: this.attendeeArray,
});
this.groupMeetingService.getMeeting(this.meeting.id).subscribe(meeting =>
{
this.meetingLocation = meeting.location;
});
this.groupMeetingService
.getReservations(this.meeting.id)
.subscribe(data => {
this.reservations = data;
this.attendeeArray = this.getAttendeeNames();
data.attendees.forEach(attendee => {
this.attendeeArray.push(this.createAttendeeName(attendee.name));
});
console.log('array', this.reservationForm);
});
}
Run Code Online (Sandbox Code Playgroud)
当我查看控制台时,它确实显示它正在被添加。上面的代码正确吗?
如果它是正确的,我如何在 HTML 中循环它并让它显示?
我尝试了很多东西但没有运气:-( …
我试图捕获表单输入字段中发生的每个删除和退格键,并且我按照以下方式执行此操作:
<input (keyup.enter)="sendData()" (keyup.delete)="clear()" (keyup.backspace)="clear()">
Run Code Online (Sandbox Code Playgroud)
它确实适用于退格键,但与左移或右移结合使用时则无效。我该如何承保这些案件?
angular ×10
ngfor ×2
sass ×2
angular-cli ×1
angular-i18n ×1
angular-pipe ×1
angular9 ×1
css ×1
debouncing ×1
environment ×1
formarray ×1
ios ×1
javascript ×1
json ×1
keyup ×1
navigateurl ×1
onchange ×1
reactjs ×1
router ×1
sonarqube ×1
styling ×1
timepicker ×1
unit-testing ×1
webstorm ×1