小编d12*_*546的帖子

angular2材质2 Datepicker - 输出日期格式

我在angular4项目中使用https://material.angular.io/components/component/datepicker.如何在输入框中用"2017年5月29日"等短格式格式化所选日期.目前显示为2017年5月29日

示例代码:

<md-input-container>
  <input mdInput readonly="true" [mdDatepicker]="startDatePicker" [mdDatepickerFilter]="myFilter" [min]="minDate" [max]="maxDate" class="date-text ng-dirty ng-valid-parse ng-touched ng-not-empty ng-valid ng-valid-required" placeholder="Choose a date">
  <button mdSuffix [mdDatepickerToggle]="startDatePicker" class="date-icon"></button>
</md-input-container>

<md-datepicker #startDatePicker [dateFormat]="'LL'" startView="month" [startAt]="currentDate"></md-datepicker>
Run Code Online (Sandbox Code Playgroud)

TS:

@ViewChild('startDatePicker') startDatePicker: MdDatepicker<Date>;
Run Code Online (Sandbox Code Playgroud)

PS.[dateFormat] ="'LL'"无效

angular-material angular

5
推荐指数
1
解决办法
4611
查看次数

AngularJS 2 TypeScript编译错误 - 类型的参数

我已经检查了我的问题的所有可能的解决方案,这基本上是指TypeScript编译.每次我启动项目时我都有:

Argument of type '{ declarations: (typeof NavbarComponent | typeof FooterComponent | typeof AboutComponent | typeof...' is not assignable to parameter of type 'NgModule'.
  Types of property 'providers' are incompatible.
    Type '(typeof BaseRequestOptions | typeof DataService | typeof UserService | typeof AuthenticationServi...' is not assignable to type 'Provider[]'.
      Type 'typeof BaseRequestOptions | typeof DataService | typeof UserService | typeof AuthenticationServic...' is not assignable to type 'Provider'.
        Type 'typeof DataService' is not assignable to type 'Provider'.
          Type 'typeof DataService' is not …
Run Code Online (Sandbox Code Playgroud)

typescript webpack angular

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

标签 统计

angular ×2

angular-material ×1

typescript ×1

webpack ×1