我的 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) 我正在尝试学习如何使用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的文档只是方法列表,没有任何解释).
我该怎么做?谢谢!
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"的客户.
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拥有属性的message?typeof myFunc结果为“函数”并console.log(myFunc)显示函数内容(没有其message上的属性)。
以上是如何工作的?JavaScript 中的函数在内部是一个对象吗?
注意 - 我知道函数还有其他参数,如原型和长度。但我不确定这些是如何实现的。
附加查询 - 由于console.log(myFunc)不显示对象属性,如何列出函数对象的所有属性?
使用 Angular Material 组件 mat-table 和 Angular Flex 布局在 div 内显示数据表。
堆栈闪电战链接
无法修复 div 内表格的宽度。如果任何列的数据较长,则表会溢出父 div。
预期的行为是为具有较长数据的列显示椭圆,并且表宽度应固定(100% 在父 div 内)并且不依赖于列数据。
angular-material angular-material2 angular-flex-layout angular