小编Ric*_*cka的帖子

如何从Visual Studio 2015中的非相对路径导入模块

我正在使用Visual Studio 2015中的gulp进行角度4项目.我Visual Studio 2015 QuickStart这里得到了它.

  • tsc版本:2.5.2

我的项目结构:

src
???angular
     ???common
           ???models
                ???items.ts
     ???ui
         ???components
                ???items.component.ts
Run Code Online (Sandbox Code Playgroud)

items.ts

export module items {
  export const listOfItems = [1,2,3];
}
Run Code Online (Sandbox Code Playgroud)

我想在导入src文件夹中的所有内容时使用非相对路径,即:

items.component.ts

import { items } from 'items';
Run Code Online (Sandbox Code Playgroud)

这是我的tsconfig.json文件(与...相同src):

{
  "compileOnSave": false,
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [ "es2015", "dom" ],
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true,
    "typeRoots": [
      "node_modules/@types/"
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)

在这里,我尝试将其添加到compilerOptions:

"baseUrl": …
Run Code Online (Sandbox Code Playgroud)

compiler-options typescript ecmascript-6 visual-studio-2015 angular

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

带有表单控件的物料日期选择器蒙版

当我将Angular 6 Material Date Picker与任何遮罩(ngx-mask,angular2-mask,angular2-text-mask)结合使用并使用时formControlName,出现错误:

错误:多个自定义值访问器将表单控件与未指定名称属性匹配

是否有适用于“物料日期选取器”和formControlName属性的蒙版?

<input matInput [matDatepicker]="myDatepicker" formControlName="dateOfbrd" mask="00/00/0000">
  <mat-error *ngFor="let validation of validationMessages.dateOfDischarge">
  <mat-error class="error-message" *ngIf=enrfrm.get('dateOfbrd').hasError(validation.type)">
    {{validation.message}}
  </mat-error>
</mat-error>
<mat-datepicker-toggle matSuffix [for]="myDatepicker"></mat-datepicker-toggle>
<mat-datepicker #myDatepicker></mat-datepicker>
Run Code Online (Sandbox Code Playgroud)

angular-material angular angular-reactive-forms

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