我有一个Angular 2应用程序,其中几乎没有类型为date的输入。默认情况下,这些日期以MM/dd/YYYY
格式显示。我需要它们的格式为dd.MM.YYYY
。我已经知道可以在app.module.ts
中进行设置,以便您指定具有这种格式的区域。
应该完成的代码是:
@NgModule({
.
.
.
providers: [AuthGuard, {provide: LOCALE_ID, useValue: 'sl'}],
bootstrap: [AppComponent]
})
这是我要格式化的HTML部分
<div class="col-lg-3">
<fieldset class="form-group">
<label>Birth date:</label>
<div class="form-group input-group">
<div class="input-group-append">
<span class="input-group-text">
<i class="fa fa-birthday-cake" aria-hidden="true"></i>
</span>
</div>
<input class="form-control" type="date" [ngModel]="birthDate" />
</div>
</fieldset>
</div>
有人知道为什么这不起作用吗?
答案 0 :(得分:0)
经过长期研究,我发现我们无法更改 let responseJson = { "Q1-2018": [ { "total_rows": 742, "avg_price": "2776280.6469", "avg_sqft_price": "1592.5728", "yr": 2018, "evidence": "ACT" }, { "total_rows": 133, "avg_price": "1381205.4436", "avg_sqft_price": "974.9925", "yr": 2018, "evidence": "MOR" }, { "total_rows": 147, "avg_price": "1730154.9524", "avg_sqft_price": "1472.4966", "yr": 2018, "evidence": "MOU" }, { "total_rows": 580, "avg_price": "1797097.3069", "avg_sqft_price": "2043.7190", "yr": 2018, "evidence": "TRA" }, { "total_rows": 61, "avg_price": "4075409.8361", "avg_sqft_price": "1415.8033", "yr": 2018, "evidence": "VAL" } ], "Q2-2018": [ { "total_rows": 1090, "avg_price": "2585032.2220", "avg_sqft_price": "1578.9303", "yr": 2018, "evidence": "ACT" }, { "total_rows": 199, "avg_price": "1426902.3769", "avg_sqft_price": "1060.0000", "yr": 2018, "evidence": "MOR" }, { "total_rows": 84, "avg_price": "1900348.8214", "avg_sqft_price": "1332.6071", "yr": 2018, "evidence": "MOU" }, { "total_rows": 638, "avg_price": "1810675.6536", "avg_sqft_price": "1681.9812", "yr": 2018, "evidence": "TRA" }, { "total_rows": 60, "avg_price": "2908750.0000", "avg_sqft_price": "1458.7667", "yr": 2018, "evidence": "VAL" } ], "Q3-2018": [ { "total_rows": 971, "avg_price": "2562323.0505", "avg_sqft_price": "1569.8218", "yr": 2018, "evidence": "ACT" }, { "total_rows": 192, "avg_price": "1574309.7813", "avg_sqft_price": "1175.7865", "yr": 2018, "evidence": "MOR" }, { "total_rows": 56, "avg_price": "1807243.6429", "avg_sqft_price": "1275.6607", "yr": 2018, "evidence": "MOU" }, { "total_rows": 371, "avg_price": "1629974.8113", "avg_sqft_price": "1389.6577", "yr": 2018, "evidence": "TRA" }, { "total_rows": 65, "avg_price": "1922692.3077", "avg_sqft_price": "1341.2615", "yr": 2018, "evidence": "VAL" } ], "Q4-2018": [ { "total_rows": 1426, "avg_price": "2541386.3191", "avg_sqft_price": "1527.2468", "yr": 2018, "evidence": "ACT" }, { "total_rows": 163, "avg_price": "1440970.0491", "avg_sqft_price": "952.3129", "yr": 2018, "evidence": "MOR" }, { "total_rows": 91, "avg_price": "1571781.8352", "avg_sqft_price": "1244.3077", "yr": 2018, "evidence": "MOU" }, { "total_rows": 429, "avg_price": "1626291.2727", "avg_sqft_price": "1434.8834", "yr": 2018, "evidence": "TRA" }, { "total_rows": 61, "avg_price": "1797540.9836", "avg_sqft_price": "1251.2623", "yr": 2018, "evidence": "VAL" } ], "Q1-2019": [ { "total_rows": 1391, "avg_price": "2755570.1855", "avg_sqft_price": "1457.6204", "yr": 2019, "evidence": "ACT" }, { "total_rows": 126, "avg_price": "1005182.1111", "avg_sqft_price": "812.4762", "yr": 2019, "evidence": "MOR" }, { "total_rows": 18, "avg_price": "1680666.6667", "avg_sqft_price": "1287.3333", "yr": 2019, "evidence": "MOU" }, { "total_rows": 362, "avg_price": "1769586.9586", "avg_sqft_price": "1506.7099", "yr": 2019, "evidence": "TRA" }, { "total_rows": 40, "avg_price": "1974375.0000", "avg_sqft_price": "1292.5500", "yr": 2019, "evidence": "VAL" }]};
let resultJson = [];
let avgJson = [];
let quarterly = [];
Object.keys(responseJson).map((value, key) => {
quarterly.push(value);
responseJson[value].map((value, key) => {
const evidence = value.evidence;
if (typeof resultJson[evidence] === "undefined") {
resultJson[evidence] = [];
}
resultJson[evidence].push(value);
console.log(
"resultJson[evidence]",
resultJson[evidence].length,
resultJson[evidence]
);
});
});
的显示格式。更改它的唯一方法是更改Chrome设置以使用本地语言。为了存档我想要的内容,您必须使用日期选择器。
这是一个例子:
Angulat material date picker
有关Chrome对我的问题的解答的详细信息,请参见以下链接(注释来自2012年,但仍可正常使用):
Chrome and input type date
谢谢大家的宝贵时间