我在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'"无效
我已经检查了我的问题的所有可能的解决方案,这基本上是指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)