本文整理汇总了TypeScript中@core/formatter.service.FormatterService类的典型用法代码示例。如果您正苦于以下问题:TypeScript service.FormatterService类的具体用法?TypeScript service.FormatterService怎么用?TypeScript service.FormatterService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了service.FormatterService类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: function
onEachFeature: function(feature: any, layer: any): void {
let formatter = new FormatterService();
if (feature.properties) {
layer.setStyle({
color: '#666',
fillColor: formatter.mmiColor(feature.properties.cdi),
fillOpacity: 0.9,
weight: 0.5
});
layer.bindPopup(this.formatPopup(feature));
}
formatter = null;
},
开发者ID:ehunter-usgs,项目名称:earthquake-eventpages,代码行数:13,代码来源:dyfi-response-overlay.ts
示例2: transform
/**
* Format a number
*
* @param value
* Number to format.
* @param decimals Optional, default does not round.
* Number of decimal places to round.
* @param units Optional, default none.
* Units of value.
* @param empty Optional, default none.
* Value to return if value is empty.
*
* @return {String}
* formatted number
*/
transform(
value: any,
decimals?: number,
units = '',
empty = this.formatter.empty
): any {
// NOTE: FormatterService uses different argument order
return this.formatter.number(value, decimals, empty, units);
}
开发者ID:ehunter-usgs,项目名称:earthquake-eventpages,代码行数:24,代码来源:number.pipe.ts
示例3: transform
/**
* Format a number
*
* @param value
* Number to format.
* @param decimals Optional, default does not round.
* Number of decimal places to round.
* @param empty Optional, default none.
* Value to return if value is empty.
* @param units Optional, default none.
* Units of value.
*
* @return {String}
* Formatted degrees string
*/
transform(
value: any,
decimals = 0,
units = '°',
empty = this.formatter.empty
): any {
// NOTE: FormatterService uses different argument order
const num = this.formatter.number(value, decimals, empty);
return `${num}${units}`;
}
开发者ID:ehunter-usgs,项目名称:earthquake-eventpages,代码行数:25,代码来源:degrees.pipe.ts
示例4: transform
transform(time: any): string {
let date;
date = new Date(time);
return this.formatter.dateTime(date);
}
开发者ID:ehunter-usgs,项目名称:earthquake-eventpages,代码行数:7,代码来源:date-time.pipe.ts
示例5: onMarkerChange
onMarkerChange() {
const latLng = this.pin.getLatLng();
let precision = 0;
try {
precision = Math.floor(this.pin._map.getZoom() / 4);
} catch (e) {}
const latitude = +this.formatter.number(latLng.lat, precision);
const longitude = +this.formatter.number(latLng.lng, precision);
const address = this.formatter.location(latitude, longitude, precision);
this.feltReport.location = {
address,
latitude,
longitude
} as Location;
}
开发者ID:emartinez-usgs,项目名称:earthquake-eventpages,代码行数:16,代码来源:map.component.ts
示例6: onMarkerChange
onMarkerChange() {
const latLng = this.pin.getLatLng();
let confidence = 0;
try {
confidence = Math.floor(this.pin._map.getZoom() / 4);
} catch (e) {}
const latitude = +this.formatter.number(latLng.lat, confidence);
const longitude = +this.formatter.number(latLng.lng, confidence);
const address = this.formatter.location(latitude, longitude, confidence);
this.geoService.method$.next('map');
this.feltReport.location = {
address,
confidence,
latitude,
longitude
} as Location;
}
开发者ID:ehunter-usgs,项目名称:earthquake-eventpages,代码行数:18,代码来源:map.component.ts
示例7: transform
/**
* Format dateTime object based on a time input
*
* @param time
* Time to be transformed into a timestamp. Must be a format readable
* by the Date JavaScript object
*
* @return {string}
* formatted date/time string. Ex: '2018-08-31 23:05:43 (UTC)'
*/
transform(time: any): string {
let date = new Date(time);
// check for valid date
if (isNaN(date.getTime()) || (!time && time !== 0)) {
date = null;
}
return this.formatter.dateTime(date);
}
开发者ID:emartinez-usgs,项目名称:earthquake-eventpages,代码行数:20,代码来源:date-time.pipe.ts
示例8: transform
/**
* Format nuumber with units
*
* @param value
* Number to format.
* @param units
* Units to describe the number.
*
* @return { String | null }
* number with units
*/
transform(
value: number | string,
units: string,
decimals: number = null): string | null {
let output: string = null;
if (value === null) {
return null;
}
switch (units) {
case 'count': {
output = value.toString();
break;
}
case 'degrees': {
const degPipe = new DegreesPipe(this.formatterService);
output = degPipe.transform(value, decimals);
break;
}
case 'latitude': {
output = this.formatterService.latitude(+value);
break;
}
case 'longitude': {
output = this.formatterService.longitude(+value);
break;
}
case 'intensity': {
output = `${value} mmi`;
break;
}
default: {
output = `${value} ${units}`;
}
}
return output;
}
开发者ID:ehunter-usgs,项目名称:earthquake-eventpages,代码行数:54,代码来源:units.pipe.ts
示例9: transform
/**
* Returns an event date time from the event
*
* @param event
* The event object
*
* @return
* New date/time formatted object
*/
transform(event: any): string {
let date;
try {
date = new Date(parseFloat(event.properties.time));
} catch (e) {
date = null;
}
return this.formatter.dateTime(date);
}
开发者ID:ehunter-usgs,项目名称:earthquake-eventpages,代码行数:20,代码来源:event-date-time.pipe.ts
注:本文中的@core/formatter.service.FormatterService类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论