我想要的内容如下图所示。我使用 Angular Material (7.x) 并使用这里描述的 Mat-Table 实现:https : //material.angular.io/components/table/overview
上面的场景是为业务展示多张销售发票。
我已经使用了 Angular 的 Mat Table 来为一行使用多行,这是有效的。但是现在我还必须使第一行(A 型)在多行表中具有多行。
我有一些关于如何使其工作的想法,但我不想开始并事先知道解决方案是否有效。
我开始遍历 salesInvoices 中的对象:
<tr mat-header-row *matHeaderRowDef="displayedPurchaseInvoiceColumns"></tr>
<ng-container *ngFor="let item of invoices.salesInvoice">
<tr mat-row class="table-first-row" *matRowDef="let row; columns: displayedSalesInvoiceColumns"></tr>
</ng-container>
<tr mat-row class="table-second-row" *matRowDef="let row; columns: displayedPurchaseInvoiceColumns"></tr>
Run Code Online (Sandbox Code Playgroud)
这没有显示任何有用的东西。我认为它甚至没有做任何事情,因为我只看到显示的购买发票,而不是销售发票。
我正在考虑在第一行使用垫子表?我不知道我是如何做到这一点的,我也不确定这是否有效。
我真的很想Mat-Table让它与它一起工作,但恐怕我无法让它与 Material 库一起工作,并且必须定制一些东西。
欢迎任何帮助!如果我需要提供更多信息,请告诉我。
我有一个来自静态 AppConfigService 的配置文件的值。如下面所描述的:
参考代码/文章:https : //blogs.msdn.microsoft.com/premier_developer/2018/03/01/angular-how-to-editable-config-files/
import { Injectable } from '@angular/core';
import { AppConfig } from './app-config';
import { HttpClient } from '@angular/common/http';
import { environment } from 'src/environments/environment';
@Injectable()
export class AppConfigService {
static settings: AppConfig;
constructor(private http: HttpClient) { }
load() {
console.log('is this getting fired before routing module check?');
const jsonFile = `assets/config/config.${environment.name}.json`;
return new Promise<void>((resolve, reject) => {
this.http.get(jsonFile)
.toPromise()
.then((response: AppConfig) => {
AppConfigService.settings = <AppConfig>response;
console.log(AppConfigService.settings);
resolve();
})
.catch((response: any) => { …Run Code Online (Sandbox Code Playgroud) 我正在使用saturn daterange-picker并使用 sat-calendar 进行日期范围选择器实现。现在,用户只能选择某个其他对象(考勤卡)还没有允许添加新条目的考勤卡的月份。
我们有一个实现,可以在(点击)事件上禁用所有这些月份,这意味着它也会被触发多年视图和有时会阻止选择的月份视图(参见 gif。)。
在我们的代码 html 中,我们有以下内容:
<sat-calendar
#calendar
[dateFilter]="filterdate"
[rangeMode]="true"
[minDate]="minDate"
[maxDate]="maxDate"
orderPeriodLabel="month"
(dateRangesChange)="onDateRangesChange(calendar, $event)"
(monthSelected)="functionName($event)"
(selectedChange)="functionName($event)"
(click)="onMonthChange(calendar)"
></sat-calendar>
Run Code Online (Sandbox Code Playgroud)
和我们的组件:
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core';
import { DateAdapter, SatCalendar, SatDatepickerRangeValue } from 'saturn-datepicker';
// left out imports
@Component({
selector: 'date-picker',
templateUrl: './date-picker.component.html',
styleUrls: ['./date-picker.component.scss'],
})
export class DatePickerComponent implements OnInit, OnChanges {
minDate: Date;
maxDate: Date;
filterdate: any;
@Input() placement: Placement;
@Input() placementTimesheets: PlacementTimesheet[];
@Output() readonly updateDateRange: …Run Code Online (Sandbox Code Playgroud) 在使用 formBuilder 和 ReactiveForms 的 Angular 7.x 中,我尝试将验证器放入基于用户角色的表单中。因此,当用户有不同的 时role,他/她需要输入一个字段。我将该用户存储在类中存储的变量中。
我不想将验证器放在 valueChange 的订阅上,而是放在初始构建上。我怎样才能做到这一点?下面是一些代码。
buildForm(): void {
this.accountForm = this.formBuilder.group({
firstName: [this.user.firstName, Validators.required],
initials: [this.user.initials, Validators.required],
lastNamePrefix: [this.user.lastNamePrefix],
lastName: [this.user.lastName, Validators.required],
cellPhoneNumber: [this.user.cellPhoneNumber], <-- make this one required if the role of the user is x
]),
});
}
Run Code Online (Sandbox Code Playgroud) 在 Angular 7.x 中,我有一个全局错误处理,可以使用注入器注入他的服务。因此每个函数都有一个对注入器的引用,如下所示:
import { ErrorHandler, Injectable, Injector, NgZone } from '@angular/core';
import { Router } from '@angular/router';
import { LoggingService } from '../logging/logging.service';
import { EnvironmentService } from '../services/environment.service';
@Injectable()
export class GlobalErrorHandler implements ErrorHandler {
constructor(private readonly injector: Injector, private readonly zone: NgZone) {}
handleError(error: any): void {
// Handle Client Error (Angular Error, ReferenceError...)
this.processError(error);
throw error;
}
processError(error: any): void {
const environmentService = this.injector.get(EnvironmentService);
const environment = environmentService.getEnvironment();
if (!environment.production) {
console.error(error);
} else …Run Code Online (Sandbox Code Playgroud) function isEqual($number1, $number2, $sum){
$total = $number1 + $number2;
if ($total = $sum){
return true;
}
else {
return false;
}
}
if (isEqual(5,5,8)){
echo 'Sum!';
}
else {
echo 'No sum!';
}
Run Code Online (Sandbox Code Playgroud)
PHP
我的作业分配说if-clause应该就是这样.因此,当$ total不等于$ sum时,它应该说:没有总和!
问题是我不应该改变if,我必须改变我的功能,因为它总是说'Sum!' 马上.
有人可以帮我弄这个吗?它应该不难,但我无法在谷歌上找到它.
这对我来说很难实际解释所以我为我想要的东西创建了一个模型.

有人可以解释我怎么做到这一点?也许一些代码可能有所帮助,但我认为一般的想法或方向就足够了.
每当在它前面打开一个新窗口时,我想让父背景变暗.
使用 Angular 7.x,我想根据子路由以及它们是否被激活来更改我的父标头组件。所以就我而言
AppComponent
Feature Module <= detect changes here
Child Components of feature module
Run Code Online (Sandbox Code Playgroud)
所以我的路由非常简单,app-routing.module只包含使用loadChildren加载功能模块,这里没什么花哨的。
然后这个功能模块包含子组件的路由。有一个父组件,我们称其ParentComponent为包含路由器出口的组件。我还想根据孩子的情况相应地更改一些标题。
所以我有两个子组件:create和 ' :id'(详细信息页面)。当我触发这些路由时,我需要父组件相应地更改其文本内容。因此,例如,当触发创建页面时,我想添加标题:“创建新项目”,对于 :id 页面,我想显示“详细信息页面”。
现在,我发现我需要订阅路由器事件或激活的路由(或快照)。我在这里不知所措,所以我真的不知道在这里做什么。
我的父组件现在看起来像这样:
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
@Component({
selector: 'parent-component',
templateUrl: './parent.component.html',
})
export class ParentComponent implements OnInit {
title = 'Parent Title';
// Check if it is possible to change the title according to the route
subtitle = 'Parent subtitle';
constructor(private readonly router: …Run Code Online (Sandbox Code Playgroud) angular ×6
javascript ×2
c# ×1
datepicker ×1
forms ×1
html ×1
jasmine ×1
karma-runner ×1
mat-table ×1
php ×1
typescript ×1
unit-testing ×1
winforms ×1