相关疑难解决方法(0)

javascript没有正确地将角度ui datepicker日期转换为UTC

我在我的项目中使用了角度ui datepicker(asp.net web api + angularjs).一切正常,但是当我试图将日期保存到Db时,它没有正确地将它转换为UTC格式并且导致1天(实际上是几个小时,但它也影响了一天).

例如,当我在datepicker中选择01/11/2014时:

Angularjs object:
Sat Nov 01 2014 00:00:00 GMT+0200 (FLE Standard Time)

In request: 
2014-10-31T22:00:00.000Z

In asp.net api controller:
{31-Oct-14 10:00:00 PM}
Run Code Online (Sandbox Code Playgroud)

Datepicker控制器:

app.controller('DatepickerCtrl', function ($scope) {
    $scope.today = function () {
        $scope.dt = new Date();
    };
    $scope.today();
    $scope.clear = function () {
        $scope.dt = null;
    };
    $scope.open = function ($event) {
        $event.preventDefault();
        $event.stopPropagation();

        $scope.opened = true;
    };
    $scope.format = 'dd/MM/yyyy';
    $scope.dateOptions = {
        'starting-day': 1
    };
});
Run Code Online (Sandbox Code Playgroud)

hnml:

<div class="form-group inputGroupContainer" ng-controller="DatepickerCtrl">
                    <label …
Run Code Online (Sandbox Code Playgroud)

javascript datepicker asp.net-web-api angularjs angular-ui

15
推荐指数
1
解决办法
1万
查看次数

AngularJS + Coffeescript - 'Hello World'指令不起作用

我不能让最简单的指令在我的AngularJS + Coffeescript项目中起作用.

我在directives.coffee中有这个代码:

'use strict'
app_name = "myApp"
app = angular.module "#{app_name}.directives", []

# Directive to include the version number of my project
app.directive 'appVersion', [
'version', (version) ->
    (scope, element, attrs) ->
    element.text version
]

# Hello world directive
app.directive 'hello', () ->
    restict: 'E'
    template: '<div>Hello World</div>'
Run Code Online (Sandbox Code Playgroud)

在我的模板中,当我这样做时

<span app-version></span>
<hello></hello>
Run Code Online (Sandbox Code Playgroud)

然后显示版本号(0.1),表明第一个指令正常工作,但标签不会被任何东西取代.

知道我做错了什么吗?

我也试过这个,但也没用:

# Hello world directive
app.directive 'hello', ->
    class Habit
        constructor: ->
            restict: 'E'
            template: '<div>Hello World</div>'
Run Code Online (Sandbox Code Playgroud)

javascript coffeescript angularjs angularjs-directive

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