小编Nit*_*iya的帖子

更漂亮的不是在 VS Code 中格式化 HTML 文件

我的 VS 代码上的漂亮扩展无法格式化 HTML。

在加载 VS 代码时,我在控制台中收到此错误 -

在此处输入图片说明

在尝试格式化时,我在底部看到此消息 -

在此处输入图片说明

注 - TS 文件和 SCSS 文件的格式正确。它仅适用于 HTML 文件。

以下是我基于 HTML 语言的设置 -

{
  "tslint.rulesDirectory": "./node_modules/codelyzer",
  "typescript.tsdk": "node_modules/typescript/lib",
  "window.zoomLevel": 0,
  "editor.formatOnSave": true,
  "prettier.singleQuote": true,
  "[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[html]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "files.associations": {
    "*.html": "html"
  }
}
Run Code Online (Sandbox Code Playgroud)

这些是安装和启用的扩展 -

在此处输入图片说明

更漂亮的版本—— 2.2.2

VS Code 版本(来自关于 VS 代码部分):

Version: 1.38.1
Commit: b37e54c98e1a74ba89e03073e5a3761284e3ffb0
Date: 2019-09-11T13:31:32.854Z
Electron: 4.2.10
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Darwin x64 …
Run Code Online (Sandbox Code Playgroud)

visual-studio-code prettier

24
推荐指数
6
解决办法
4万
查看次数

如何在Angular 5 HttpInterceptor中添加多个头文件

我正在尝试学习如何使用HttpInterceptor为应用程序对API执行的每个HTTP请求添加几个标头.我有这个拦截器:

import { Injectable } from '@angular/core';

import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http';

import { Observable } from 'rxjs/Observable';


@Injectable()
export class fwcAPIInterceptor implements HttpInterceptor {
  intercept (req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {

  const authReq = req.clone({
    headers: req.headers.set('Content-Type', 'application/json')
  });

  console.log('Intercepted HTTP call', authReq);

  return next.handle(authReq);
}
}
Run Code Online (Sandbox Code Playgroud)

}

除了'Content-Type'标题之外,我还需要添加'Authorization',但我不知道怎么做(Angular HttpHeaders的文档只是方法列表,没有任何解释).

我该怎么做?谢谢!

angular-http-interceptors angular angular-httpclient

19
推荐指数
4
解决办法
3万
查看次数

用于流程图生成器或工作流编辑器的Angular库

我目前正在寻找用于角度生成器的前端Webapp的流程图生成器或工作流编辑器的开源库。

我看过jsplumbjointjs。但是这两个库的角度包装器均已获得许可。

我也检查了mxgraph。但是没有可用的角度包装器。

请让我知道是否有人使用开源库以角度实现了流程图生成器或工作流编辑器。

workflow flowchart angular

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

如何在angularJS中隐藏表格中的行?

HTML代码显示表 -

    <table class="table table-bordered table-striped table-condensed">
        <thead class="TableHeader"> 
            <tr>
                <th>Role</th>
                <th>Name</th>
                <th>ID</th>
            </tr>
        </thead>
        <tbody> 
            <tr ng-repeat="i in allCustomerInfoArray track by $index" ng-click="showCustomerinfo($index)">
                <td>{{i.role }}</td>
                <td>{{i.name}}</td>
                <td>{{i.id}}</td>
            </tr>
        </tbody>
    </table>
Run Code Online (Sandbox Code Playgroud)

Angular JS代码在控制台日志中显示客户信息 -

    $scope.showCustomerinfo=function(index) {
        console.log("table clicked row -- "+index);
        console.log("DOB -- "+$scope.allCustomerInfoArray[index].role);
        console.log("Age -- "+$scope.allCustomerInfoArray[index].name);
        console.log("Age -- "+$scope.allCustomerInfoArray[index].id);
        console.log("DOB -- "+$scope.allCustomerInfoArray[index].dob);
        console.log("Age -- "+$scope.allCustomerInfoArray[index].age);
    }
Run Code Online (Sandbox Code Playgroud)

现在我想修改上面的代码来隐藏客户角色为"XXX"的行.请让我知道如何实现它.

注 - 我不想从allCustomerInfoArray中删除角色为"XXX"的客户.

javascript angularjs

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

javascript 函数中如何具有属性?

function myFunc(){
    console.log(myFunc.message);
}
myFunc.message = "Hi John";

myFunc();
Run Code Online (Sandbox Code Playgroud)

执行上述结果 -

Answer: 'Hi John'
Run Code Online (Sandbox Code Playgroud)

函数是如何myFunc拥有属性的messagetypeof myFunc结果为“函数”并console.log(myFunc)显示函数内容(没有其message上的属性)。

以上是如何工作的?JavaScript 中的函数在内部是一个对象吗?

注意 - 我知道函数还有其他参数,如原型和长度。但我不确定这些是如何实现的。

附加查询 - 由于console.log(myFunc)不显示对象属性,如何列出函数对象的所有属性?

javascript javascript-objects

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

mat-table - 如果任何列的内容很长,则溢出父级 div

使用 Angular Material 组件 mat-table 和 Angular Flex 布局在 div 内显示数据表。

堆栈闪电战链接

无法修复 div 内表格的宽度。如果任何列的数据较长,则表会溢出父 div。

预期的行为是为具有较长数据的列显示椭圆,并且表宽度应固定(100% 在父 div 内)并且不依赖于列数据。

angular-material angular-material2 angular-flex-layout angular

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

无法使用角度柔性布局设置 ngx-quill 编辑器的高度

无法使用角度柔性布局设置 ngx-quill 编辑器的高度。

编辑器的高度(灰色边框)溢出了父 div(红色背景)。

堆栈闪电战

如何确保编辑器位于父 div 内?

css flexbox quill angular-flex-layout ngx-quill

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