当我ng build -prod --aot只运行.js文件时.
输出:
chunk {0} polyfills.a2079361c5ff6d4e321e.bundle.js (polyfills) 285 kB {5} [initial] [rendered]
chunk {1} main.d19edcafc399a0af8c0b.bundle.js (main) 2.33 MB {4} [initial] [rendered]
chunk {2} scripts.22988bec4cd6ce344e9f.bundle.js (scripts) 973 kB {5} [initial] [rendered]
chunk {3} styles.99705fb1bf9015185149.bundle.css (styles) 705 bytes {5} [initial] [rendered]
chunk {4} vendor.377addf0a4997a085d42.bundle.js (vendor) 4.71 MB [initial] [rendered]
chunk {5} inline.911ff25c95430bbf496e.bundle.js (inline) 0 bytes [entry] [rendered]
Run Code Online (Sandbox Code Playgroud)
我的问题是:
我跟着这个github故事:https://github.com/angular/angular-cli/wiki/stories-configure-hmr
我可以在自动刷新后查看更改ng serve(环境是开发),但是ng serve --hmr -e=hmr,页面会自动刷新(如闪烁)而不进行更改.我必须按下F5才能看到变化.
HMR工作正常,因为我看到我的终端输出如下:
NOTICE Hot Module Replacement (HMR) is enabled for the dev server.
The project will still live reload when HMR is enabled,
but to take advantage of HMR additional application code is required
(not included in an Angular CLI project by default).
See https://webpack.github.io/docs/hot-module-replacement.html
for information on working with HMR for Webpack.
To disable this warning use "ng set --global warnings.hmrWarning=false"
** NG Live Development …Run Code Online (Sandbox Code Playgroud) 我有一个带有3个兄弟组件的Angular应用程序,它们能够访问和更新变量"data".它们连接到路由器,但我想传递的数据是敏感的(api端点确定折扣)所以我不能使用cmp2 /:data
组件1有一个称为数据的对象,组件2和3需要接收这个数据对象.我认为这可以通过共享服务完成,但我不太确定如何让这个事件发射器工作..
我的index.html:
<router-outlet></router-outlet>
Run Code Online (Sandbox Code Playgroud)
第1部分:
<button [routerLink]=['cmp2/']>Go to Comp 2 </button>
<button [routerLink]=['cmp3/']>Go to Comp 3 </button>
Run Code Online (Sandbox Code Playgroud)
组件2和3:
{{ data }}
Run Code Online (Sandbox Code Playgroud) 我的 API 限制为每秒 10 次调用(但每天数千次),但是,当我运行此函数时(调用对象的每个样式 ID,> 每秒 10 次):
getStyleByID(styleID: number): void {
this._EdmundsAPIService.getStyleByID(styleID).subscribe(
style => {this.style.push(style); },
error => this.errorMessage = <any>error);
}
Run Code Online (Sandbox Code Playgroud)
从这个函数(只有 1 次调用,使用 onInit):
getStylesWithoutYear(): void {
this._EdmundsAPIService.getStylesWithoutYear(this.makeNiceName, this.modelNiceName, this.modelCategory)
.subscribe(
styles => { this.styles = styles;
this.styles.years.forEach(year =>
year.styles.forEach(style =>
this.getStyleByID(style.id)));
console.log(this.styles); },
error => this.errorMessage = <any>error);
}
Run Code Online (Sandbox Code Playgroud)
它每秒进行 > 10 个呼叫。如何限制或减慢这些调用以防止出现 403 错误?
根据材料设计规范:
在台式机上,卡片的静止高度可以为0dp,悬停时可以达到8dp。
如何使用Angular Material 2创建此动画效果?
我考虑过(hover)=用动画来做这个。我不太在乎这种方法,我希望它在悬停时提升。原因是,我在用户界面中将卡片用作按钮。
我有一些按钮
<button mdTooltip="bye" mdTooltipPosition="left" md-mini-fab>
BYE
</button>
<button mdTooltip="hi" mdTooltipPosition="left" md-mini-fab>
HI
</button>
Run Code Online (Sandbox Code Playgroud)
默认情况下,工具提示显示在“悬停”上。有没有办法让它一直显示?(在页面加载和停留时显示)
所以我有以下场景; 我有一个私有API密钥,Angular将在XHR请求中显示.为了解决这个问题,我决定使用Express作为代理并提出服务器端请求.但是,我似乎无法找到有关如何制作自己的get请求的文档.
建筑:
Angular请求/api/external-api- > Express处理路由并向externalURLparams 发出请求req.body.params并附加API密钥config.apiKey.以下是伪模式来模仿我想要完成的事情:
router.get('/external-api', (req, res) => {
externalRestGetRequest(externalURL, req.body.params, config.apiKey)
res.send({ /* get response here */})
}
Run Code Online (Sandbox Code Playgroud) 我有一个存储十六进制颜色值的 JSON 文件option.colorChips.primary.hex,我想为每种颜色创建一个按钮,其中按钮的背景就是相关的颜色。(注:option.colorChips.primary.hex仅包含6位十六进制代码,不包含#)
这是我的模板:
<ng-container *ngFor="let color of style.colors">
<h1>{{ color.category }}</h1>
<ng-container *ngFor="let option of color.options">
<button [style.background]="option.colorChips.primary.hex">{{ option.name }} Color </button><br />
{{ option.colorChips.primary.hex }} <br />
</ng-container>
<hr />
</ng-container>
Run Code Online (Sandbox Code Playgroud)
你可以在第 4 行看到我的尝试。为什么这不起作用?
我已经创建了自己的json数据,我希望将数组解析为python列表.但是,我一直遇到麻烦.
如何将我的json数组提取到python列表中?
json数据:
[
{
"ip": "192.168.241.109",
"cameras":
{
"front": "nf091",
"inside": "nf067",
"right": "004317",
"rear": "000189",
"left": "nf084"
}
},
{
"ip": "192.168.241.110",
"cameras":
{
"front": "nf091",
"inside": "nf067",
"right": "004317",
"rear": "000189",
"left": "nf084"
}
}
]
Run Code Online (Sandbox Code Playgroud)
我的json数据是有效的,所以我不知道为什么我在使用下面的代码时遇到问题:
system_json = open(json_file)
json_obj = json.load(system_json)
camera_details = [[i['front'], i['rear'], i['left'], i['right'], i['inside']] for i in json_obj['cameras']]
Run Code Online (Sandbox Code Playgroud)
上面的代码段不起作用,因为它会产生list indices must be integers, not str错误.
我做错了什么,如何正确解析我的json数组到python列表?
有没有办法将 Angular 的风格指南集成到 WebStorm 中?
特别是,自动导入使用双引号而不是单引号,导入 {Component} 而不是 { Component },以及导出: [Component] 而不是 [ Component ]。
每次我需要重新格式化我的代码时手动修复这真的很烦人CTRL+Shift+L
我正在尝试创建以下UI/UX按钮:
.. [2015] [2016] [2017]
默认情况下,当前年份(在撰写时,2017年)被"选中",当用户点击"2015"时,应取消选择"2017"和"2016"(这些按钮是"互斥的")
这些按钮是从外部数据源生成的,该数据源为我提供了多年的数据:
<button *ngFor="let year of styles.years" type="button" name="button" class="btn btn-default" id="{{year.year}}">
{{year.year}}
</button>
Run Code Online (Sandbox Code Playgroud)
如何创建一个按钮系统,其中一个按钮被"自动选择",当选择"其他"按钮时,它会取消选择主动选择的按钮,并将现在单击的按钮设置为"已选择"?
我试图多次查询我的数据库并构建一个对象,该对象在一个字段中存储我的数据库的每个响应.这是我的代码:
router.post('/search', (req, res) => {
var collection = db.get().collection('styles')
var data = [];
collection.distinct('make.name', (err, docs) => {
data.push({'make': docs });
});
collection.distinct('model', (function (err, docs) {
data.push({'model': docs });
}))
res.send(data);
});
Run Code Online (Sandbox Code Playgroud)
由于NodeJS/Express是异步的,因此无法正常工作.如何重建此端点以进行多个数据库调用(来自同一个集合)并返回包含它的对象?
angular ×9
angular-cli ×2
express ×2
javascript ×2
node.js ×2
rest ×2
angularjs ×1
arrays ×1
css ×1
json ×1
list ×1
python-2.7 ×1
webpack ×1
webstorm ×1