首页 > 解决方案 > 如何根据 ng-model 值设置输入类型 =“日期”的日期

问题描述

我在 $scope 中有一个日期。当页面加载时,我希望在 $scope 中的值上设置输入 type="date" 字段值。

<input class="form-control" type="date"
        ng-model="asso.formation_of_association"
        placeholder="" />

但我只dd-mm-yyy在输入字段上看到

标签: angularjs

解决方案


您应该展示您的代码,因为我准备了一个示例并且它有效。

<div ng-app>
  <div ng-controller="myCtrl">
    <input type="date" ng-model="date.formation_of_association">
  </div>
</div>

function myCtrl($scope) {

  $scope.asso = {
    'formation_of_association': '2018-06-21'
  };

}

推荐阅读