Error: [ngModel:datefmt] Expected `2015-05-29T19:06:16.693209Z` to be a date - Angular

前端 未结 8 682
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 07:10

I\'m working on angularapplication with Django with rest-framework..

The app receives it\'s info with json from the server.. O

8条回答
  •  情深已故
    2020-11-29 07:50

    Create a simple directive that converts the model value:

    HTML:

    
    

    Directive:

    app.directive('dateInput', function(){
        return {
            restrict : 'A',
            scope : {
                ngModel : '='
            },
            link: function (scope) {
                if (scope.ngModel) scope.ngModel = new Date(scope.ngModel);
            }
        }
    });
    

提交回复
热议问题