在我的 Angular 5 应用程序中,我已经 angular-cli 1.6.8
{
"name": "test",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"karma": "ng test",
"test": "jest",
"test:watch": "jest --watch",
"test:ci": "jest --runInBand",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.7",
"@angular/common": "^5.2.7",
"@angular/compiler": "^5.2.7",
"@angular/core": "^5.2.7",
"@angular/forms": "^5.2.7",
"@angular/http": "^5.2.7",
"@angular/platform-browser": "^5.2.7",
"@angular/platform-browser-dynamic": "^5.2.7",
"@angular/platform-server": "^5.2.7",
"@angular/router": "^5.2.7",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"hammerjs": "^2.0.8",
"lodash": "^4.12.0",
"moment": "^2.18.1",
"npm": "^5.2.0",
"proxy-polyfill": …Run Code Online (Sandbox Code Playgroud) 我有一个在 ubuntu 终端上运行的 perl 脚本文件
所以在运行时,我像这样调用它:
./myscript.pl
Run Code Online (Sandbox Code Playgroud)
在运行时,在终端下,它开始要求我应该进行一些“确认”(用于配置),如下所示:
然后,另一次与另一个要求“确认”
,然后在其他几乎 10 次不同的配置确认中,我总是点击默认选项。
所以我的目的是如何能够一次完成,仅在一行命令中,然后能够将它放在 bash_profile 下。
我会试试这个:
./myscript.pl "yes" "yes "no" ..... "yes"
Run Code Online (Sandbox Code Playgroud)
但我不知道这是否可行。
在我的 Reactjs 应用程序中,我想添加一个拦截器,它可以将一些标头附加到某些后端响应中
所以,我尝试了这个:
export default function App() {
axios.interceptors.response.use(
(config)=> {
config.headers['myheader'] = 'myvalue'; // <-- THIS IS MY CUSTOM HEADERS
return config;
},
(error) => {
// ON ERREOR
})
......
);
Run Code Online (Sandbox Code Playgroud)
我想我的标头将附加在每个后端响应中。但这似乎不起作用。
建议??
我正在循环我的数据列表并在视图中显示,作为 spans 标签:
<span *ngFor="let d of myData; last as isLast">
{{d.name}}
<span *ngIf="!isLast">,</span>
</span>
Run Code Online (Sandbox Code Playgroud)
如您所见,我添加了一个逗号 '**, betewen items values
这看起来像这样 ::
AAA,BBB,CCC,DDD,
Run Code Online (Sandbox Code Playgroud)
但碰巧我的数据是空的:所以我想显示一些自定义字符串: "NO ITEMS"
我想在 html 部分用管道处理它
建议?
我有这个字符串数组:
let myArray : ["AA","BB" , "CC" ...]
Run Code Online (Sandbox Code Playgroud)
我想将其转换为对象数组:
myArray = [{"id":1 , "value": "AAA"},{"id":2 , "value": "BBB"},{"id":3 , "value": "CCC"}...]
Run Code Online (Sandbox Code Playgroud)
我和"让我"一起玩:
for (let obj of ListObj) {
let resObj = {};
resObj ['value'] = obj ;
equipment = resObj ;
}
Run Code Online (Sandbox Code Playgroud)
并与地图:
ListObj.map(obj => { 'value' = obj })
Run Code Online (Sandbox Code Playgroud)
建议?
我有一个名称如下所示的容器列表:
容器 1:myApp_ ihm .dfgdfgdfgdfvdfdfbvdfvdfv
容器 2:myApp_back.uirthjhiliszfhjuioomlui ...
容器 3: myApp_database.piyrjfhjyukyujfkgft
我必须在名称包含ihm的容器上执行一些字符串(我的示例中的第一个)
为了执行我的命令,我习惯于这样做:
docker exec -it ihm bash
Run Code Online (Sandbox Code Playgroud)
所以ihm应该用一些测试代替以获得第一个名称:
myApp_ihm.dfgdfgdfgdfvdfdfbvdfvdfv
建议?
我正从Http迁移到HttpClient, 我习惯将一些标头添加到我的http请求中,如下所示:
import { RequestOptions, Request, RequestMethod, Headers } from '@angular/http';
this.pass = btoa(cuid + ': ');
this.pass = "Basic " + this.pass;
this.header = new Headers();
this.header.set("Authorization", this.pass);
let options = new RequestOptions({
headers: this.header
});
return this.http.post(myServiceUrl, {}, options)
Run Code Online (Sandbox Code Playgroud)
现在,当迁移到httpClient时,我已经尝试过:
import {HttpClient, HttpHeaders} from '@angular/common/http';
const header = new HttpHeaders();
const pass = 'Basic ' + btoa(cuid + ': ');
header.set('Authorization', pass);
const options = ({
headers: header
});
return this.httpClient.post(myServiceUrl, {}, options); …Run Code Online (Sandbox Code Playgroud) 我循环我的数据列表,并在span中显示在视图中:
<span *ngFor="let d of myData"> {{d.name}} ,</span>
Run Code Online (Sandbox Code Playgroud)
如您所见,我在每个项目的末尾添加逗号' , '以获取一致的视图
这导致我的外观如下:
AAA,BBB,CCC,DDD,
Run Code Online (Sandbox Code Playgroud)
我的问题是**我要自动删除的最后一个逗号。
建议?
angular ×5
javascript ×4
typescript ×3
angular5 ×2
angular6 ×2
angular-cli ×1
angular-http ×1
axios ×1
bash ×1
docker ×1
node.js ×1
npm ×1
perl ×1
powershell ×1
prototype ×1
reactjs ×1
shell ×1