小编Ani*_*had的帖子

按年和月排序数组

我有如下数组,

let  yearAndMonth  =  [
    { "year": 2013, "month": "FEBRUARY" },
    { "year": 2015, "month": "MARCH" },
    { "year": 2013, "month": "JANUARY" },
    { "year": 2015, "month": "FEBRUARY" }
]
Run Code Online (Sandbox Code Playgroud)

我希望按年份排序数组,然后在该年的那个之后对数组进行排序,

我想要像这样的输出,

yearAndMonth  =  [
    { "year": 2013, "month": "JANUARY " },
    { "year": 2013, "month": "FEBRUARY" },
    { "year": 2015, "month": "FEBRUARY" },
    { "year": 2015, "month": "MARCH" }
]
Run Code Online (Sandbox Code Playgroud)

怎么做到这一点?

javascript arrays sorting lodash angular

8
推荐指数
2
解决办法
1769
查看次数

位置2的文字异常

我在html页面上显示时遇到此错误,我以数组形式返回日期。如果我想只显示将来的月份和年份,那应该怎么办?现在我想返回整个日期,所以html上有错误我正在显示date2 [i]的ngmodel中的p-calendar标签中的页面,其中我是来自p-datalist的索引,我在html页面上遇到了错误

educationform.component.html:298错误错误:Object.debugCheckAndUpdateView处callWithDebugContext(services.js:871)处viewWrappedDebugError(errors.js:42)处位置2处的文字异常[如ViewRef_处的checkAndUpdateView](services.js:385) ZoneDelegate.invoke(区域)的eval(application_ref.js:575)的Array.forEach()处的val(application_ref.js:742)的.detectChanges(refs.js:508) .js?1534930465821:388),位于Object.onInvoke(ng_zone.js:594)View_EducationFormComponent_1 @ educationform.component.html:298 educationform.component.html:298错误上下文DebugContext_

<p-calendar [(ngModel)]="date2[i]" formControlName="startdate" [monthNavigator]="true" [yearNavigator]="true" yearRange="1950:2040"
                                    [showIcon]="true" dateFormat="dd.mm.yy" name="calendar"></p-calendar>
Run Code Online (Sandbox Code Playgroud)

Person.js

{
"EducationDegrees":[{

                "EducationId":1001,
                "InstituteName":"SPIT",
                "EducationType":"Professional",
                "Degree":"Mca",
                "University":"Mumbai",
                "MarksObtain":90,
                "OutOf":100,
                "Percentage":90,
                "PassingYear":"2016",
                "Stream":"Computer Science",
                "Grade":"A",
                "CourseDuration":3,
                "StartDate":"2005-05-05",
                "ExpectedEndDate":"4/2018",
                "ActualEndDate":"4/2018"

        }],
}
Run Code Online (Sandbox Code Playgroud)

education.component.html

<p-calendar [(ngModel)]="date2[i]" formControlName="startdate" [monthNavigator]="true" [yearNavigator]="true" yearRange="1950:2040"
                                    [showIcon]="true" dateFormat="dd.mm.yy" name="calendar"></p-calendar>
Run Code Online (Sandbox Code Playgroud)

教育组成部分

import { Component, OnInit } from '@angular/core';
import {SelectItem} from 'primeng/api';
import { Message } from 'primeng/components/common/api';
import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms';
import { PersonListService,Person, EducationDegree} from …
Run Code Online (Sandbox Code Playgroud)

angular

4
推荐指数
1
解决办法
5819
查看次数

如何在@ ng-select / ng-select选项上显示工具提示

我在应用程序中使用@ ng-select / ng-select @ 2.3.6,并且数组中有很长的文本。

因此,完整的文本在下拉列表中不可见,因此我想在每个选项上显示标题/工具提示

我试过了,

let listArray = [{name: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s'}];

<ng-select placeholder="Select" (change)="onChange($event)">
      <ng-option *ngFor="let list of listArray" 
       title="{{list.name}}"> {{list.name}} </ng-option>
 </ng-select>
Run Code Online (Sandbox Code Playgroud)

但是没有运气

angular angular6

3
推荐指数
1
解决办法
4817
查看次数

Mat Paginator 无法在材质表上使用 FormArray

我正在使用带有 formArray 的 mat-table,我还需要 Mat-paginator。

但不幸的是分页不起作用。

Stackbltiz 演示

样本来源,

.html

<form [formGroup]="form">
  <table mat-table [dataSource]="dataSource" formArrayName="dates">
    <!-- Row definitions -->
    <tr mat-header-row *matHeaderRowDef="displayColumns"></tr>
    <tr mat-row *matRowDef="let row; let i = index; columns: displayColumns;"></tr>

    <!-- Column definitions -->
    <ng-container matColumnDef="from">
      <th mat-header-cell *matHeaderCellDef> From </th>
      <td mat-cell *matCellDef="let row; let index = index"  [formGroupName]="index"> 
        <input type="date" formControlName="from" placeholder="From date">
      </td>
    </ng-container>

    <ng-container matColumnDef="to">
      <th mat-header-cell *matHeaderCellDef> To </th>
      <td mat-cell *matCellDef="let row; let index = index"  [formGroupName]="index">
        <input type="date" formControlName="to" placeholder="To …
Run Code Online (Sandbox Code Playgroud)

angular-material angular7 mat-table mat-pagination

3
推荐指数
1
解决办法
2015
查看次数

符号“$”在角度中意味着什么?

${some_var} 中的$是什么意思

search(term:string) {
        let promise = new Promise((resolve, reject) => {
        let apiURL = `${this.apiRoot}?term=${term}&media=music&limit=20`;
        this.http.get(apiURL)
            .toPromise()
            .then(
            res => { // Success
                console.log(res.json());
                resolve();
                   }
                 );
        });
        return promise;
    }
Run Code Online (Sandbox Code Playgroud)

angular

2
推荐指数
1
解决办法
7819
查看次数

刷新 浏览器 Angular 应用程序不工作。将应用程序部署到 apache tomcat 时出现 404 错误

我试图找出如何设置 Apache Tomcat 服务器以在页面刷新时为 Angular 应用程序提供服务的方法。

路由仅在我单击时才起作用,但如果手动输入路径或者如果我进行页面刷新,则会出现 404 错误。

HTTP 状态 404 – 未找到

1)构建角度应用程序:

ng build --prod --base-href ./
Run Code Online (Sandbox Code Playgroud)

2)我还在apache tomcat中添加了重写规则

在 $ApacheLocation/conf/context.xml 中

<Valve className="org.apache.catalina.valves.rewrite.RewriteValve" />
Run Code Online (Sandbox Code Playgroud)

在 $ApacheLocation/conf/server.xml

<Valve className="org.apache.catalina.valves.rewrite.RewriteValve" />
Run Code Online (Sandbox Code Playgroud)

但它对我不起作用。

我将不胜感激任何帮助。

tomcat production-environment angular angular6

2
推荐指数
1
解决办法
3531
查看次数