I would like to use zone.js in my Angular project ( not just the runOutsideAngularZone function ).
I tried to include it like this:
import { zone } from 'zone.js';
Run Code Online (Sandbox Code Playgroud)
Unfortunately I get this error:
error TS2306: File 'C:/projects/MyApp/node_modules/zone.js/dist/zone.js.d.ts' is not a module.
Run Code Online (Sandbox Code Playgroud)
Then I removed the { zone } part:
import 'zone.js';
Run Code Online (Sandbox Code Playgroud)
But now I get this error:
error TS2552: Cannot find name 'zone'. Did you mean 'Zone'?
Run Code Online (Sandbox Code Playgroud)
My code is this:
let myZoneSpec = {
beforeTask: function () …Run Code Online (Sandbox Code Playgroud) 我正在使用datetimepicker,需要将从params获得的字符串datetime保存到特定于用户的特定时区中的datetime。这将使我可以将适当的UTC日期时间保存到数据库中。
params[:notify_at] #=> "2014-07-05 14:30:00"
user.time_zone #=> #<ActiveSupport::TimeZone:0x00000007535ac8 @name="Warsaw", @utc_offset=nil, @tzinfo=#<TZInfo::TimezoneProxy: Europe/Warsaw>, @current_period=nil>
Run Code Online (Sandbox Code Playgroud)
我想做些类似的事情:
date = params[:notify_at].to_datetime(user.time_zone) #=> Sat, 05 Jul 2014 12:30:00 +0000
(its 14:30 in user's localtime but 12:30 in UTC)
Run Code Online (Sandbox Code Playgroud) 我有一个充满用户的数据库,每个用户都有一个timezone存储为字符串的列(例如America/New_York).(而且我知道将它们作为偏移存储在数据库中会更有意义,但不能为此项目完成)我有一个表单,用户可以更改其时区.这是我的第一个方法:
我有这个填充下拉(value=> display):
protected $timezones = [
'+00:00' => '(UTC +00:00) Western European Time',
'+01:00' => '(UTC +01:00) Central European Time',
'+02:00' => '(UTC +02:00) Eastern European Time',
'+03:00' => '(UTC +03:00) Further-Eastern European Time',
'+04:00' => '(UTC +04:00) Gulf Standard Time',
'+05:00' => '(UTC +05:00) Pakistan Standard Time',
'+05:30' => '(UTC +05:30) Indian Standard Time',
'+05:45' => '(UTC +05:45) Nepal Time',
'+06:00' => '(UTC +06:00) British Indian Ocean Time',
'+07:00' => '(UTC …Run Code Online (Sandbox Code Playgroud) 我有一个本地脚本角度应用程序,它运行蓝牙服务来连接到外围设备(设备)。该应用程序会显示一个标签,其中包含一条消息,指示尚未将蓝牙设备连接到运行该应用程序的移动设备。我想做的是更新 UI,以便标签在发生连接时消失(并在发生断开连接时重新出现)。
应用程序组件.tns.html
<StackLayout orientation="vertical" marginBottom="50">
<Label text="No bluetooth device detected." id="noBluetoothWarning" horizontalAlignment="center" color="#B11" *ngIf="bluetoothDisconnected" marginTop="30" visibility="{{ isBluetoothConnected ? 'collapsed' : 'visible' }}"></Label>
</StackLayout>
Run Code Online (Sandbox Code Playgroud)
应用程序组件.ts
export class NSAppComponent extends AppComponent implements OnInit {
pageData: Observable;
ngOnInit() {
this.bluetoothDisconnected = true;
let _page = <Page>topmost().currentPage;
_page.actionBarHidden = true;
_page.frame.bindingContext = this.pageData;
let that = this;
this.bluetoothScanner.connectionStateChangeEvent.subscribe((connectionState) => {
that.log.debug(`Am I in an angular zone? ${NgZone.isInAngularZone()}`);
this.ngZone.run(() => {
that.log.debug(`connectionStateEvent triggered! state is: ${connectionState}`);
that.bluetoothDisconnected = !connectionState;
that.pageData.set("isBluetoothConnected", connectionState);
that.pageData.notify({ object: that.pageData, …Run Code Online (Sandbox Code Playgroud) zone ×4
angular ×2
datetime ×2
time ×2
javascript ×1
nativescript ×1
php ×1
ruby ×1
timezone ×1