我想基于用户类型设置'date -input'的授权服务。我使用'ServiceName.getMethod',然后尝试通过创建类来解决它,但它无法解决。
export class SchoolDateFormat {
public schoolDateFormat = '';
constructor(private auth: AuthenticationService) {
if ( this.auth.isLoggedIn() ) {
if ( this.auth.isSystemUser() ) {
this.schoolDateFormat = this.auth.getCountryDateFormat();
}else {
this.schoolDateFormat = 'YYYY-MM-DD';
}
}else {
this.schoolDateFormat = 'YYYY-MM-DD';
}
}
get getDateFormat() {
return this.schoolDateFormat;
}
}
const schoolDate = new SchoolDateFormat([AuthenticationService]);
export const MY_FORMATS = {
parse: {
dateInput: 'YYYY-MM-D',
},
display: {
dateInput: schoolDate.getDateFormat,
monthYearLabel: 'MMM YYYY',
dateA11yLabel: 'LL',
monthYearA11yLabel: 'MMMM YYYY',
},
};
我在cookie中设置了此值,并从cookie获取数据来处理此问题。