我按照角度材料网站上的说明进行了操作. https://material.angularjs.org/latest/#/demo/material.components.menu
我遇到的问题是简单的下拉菜单和快速拨号只是静态而不是初始化.
似乎无法弄清楚我错过了什么.
<div layout="column">
<md-content class="md-padding" layout="column">
<div class="lock-size" layout="row" layout-align="center center">
<md-fab-speed-dial md-open="false" md-direction="up"
ng-class="md-fling">
<md-fab-trigger>
<md-button aria-label="menu" class="md-fab md-warn">
<i class="fa fa-car"></i>
</md-button>
</md-fab-trigger>
<md-fab-actions>
<md-button aria-label="twitter" class="md-fab md-raised md-mini">
<i class="fa fa-car"></i>
</md-button>
<md-button aria-label="facebook" class="md-fab md-raised md-mini">
<i class="fa fa-car"></i>
</md-button>
<md-button aria-label="Google hangout" class="md-fab md-raised md-mini">
<i class="fa fa-car"></i>
</md-button>
</md-fab-actions>
</md-fab-speed-dial>
</div>
</md-content>
</div>
Run Code Online (Sandbox Code Playgroud) 如何在组合中应用"prefetch_related"和"values"方法?
以前,我有以下代码.优化性能需要限制此查询中的字段.
Organizations.objects.values('id','name').order_by('name')
Run Code Online (Sandbox Code Playgroud)
现在,我需要预取其关联并使用"prefetch_related"方法将其附加到序列化程序中.
Organizations.objects.prefetch_related('locations').order_by('name')
Run Code Online (Sandbox Code Playgroud)
在这里,我似乎找不到使用"prefetch_related"后限制字段的方法.
我尝试过以下操作,但是这样做时序列化程序没有看到相关的"位置".
Organizations.objects.prefetch_related('locations').values("id", "name").order_by('name')
Run Code Online (Sandbox Code Playgroud)
模型骨架:
class Organizations(models.Model):
name = models.CharField(max_length=40)
class Location(models.Model):
name = models.CharField(max_length=50)
organization = models.ForeignKey(Organizations, to_field="name", db_column="organization_name", related_name='locations')
class Meta:
db_table = u'locations'
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 pm2 在午夜运行 cron。
通过这种设置,我面临着一个意想不到的情况,即一旦我启动进程,就会触发 cron 一次。
有没有一种方法可以配置此功能而无需验证 cron 进程中的运行时间?
生态系统.config.js
module.exports = {
apps: [
{
name: "server",
script: "server.js",
watch: false,
env: {
NODE_ENV: "production"
}
},
{
name: "test-cron",
script: "test-cron.js",
instances: 1,
exec_mode: "fork",
cron_restart: "0 0 * * *",
watch: false,
autorestart: false,
env: {
NODE_ENV: "production"
}
}
]
};
Run Code Online (Sandbox Code Playgroud)
命令
pm2-runtime ecosystem.config.js
Run Code Online (Sandbox Code Playgroud)
测试 cron.js
console.log("CRON EXECUTED");
Run Code Online (Sandbox Code Playgroud)
控制台输出:
> pm2-test@1.0.0 start /Users/sudhirshrestha/workspace/pm2-test
> pm2-runtime ecosystem.config.js
2019-08-28T22:54:44: PM2 log: Launching in no daemon mode
2019-08-28T22:54:44: …Run Code Online (Sandbox Code Playgroud) 为什么md-chip不支持ng-repeat?
<md-chips>
<md-chip data-ng-repeat="category in book.categories">
{{category.name}}
</md-chip>
</md-chips>
Run Code Online (Sandbox Code Playgroud) 在我的ember应用程序中,我有一个对象数组.我需要操纵数组中的一些对象.
例如:数组:[{a:1}]然后我需要将a更改为2.
someArray: [{a: 1}],
didInsertElement() {
var self = this;
this.$('.some-element').on('scroll',function() {
self.get('someArray')[0]['a'] = 2; // HOW TO DO THIS ?
});
}
Run Code Online (Sandbox Code Playgroud)
此外,我还需要将更改反映在视图中.
注意:Ember版本1.13
我有一个视图,需要在单击按钮时进行ajax调用。在处理请求期间,如果用户不必要地单击,我不希望请求堆积。为了阻止多个请求,我进行了以下设置。
视野中
<button ng-click="getBooks()"></button>
Run Code Online (Sandbox Code Playgroud)
在控制器中
var ajaxInProgress = false;
$scope.getBooks = function () {
if (ajaxInProgress) {
return false;
}
ajaxInProgress = true;
BooksFactory
.getBooks()
.then(function (response) {
ajaxInProgress = false;
})
.catch(function() {
ajaxInProgress = false;
});
};
Run Code Online (Sandbox Code Playgroud)
这对我来说效果很好,但是将其添加到同一视图中的多个此类函数中时,控制器开始变得混乱。有没有更好的解决方案来清理这个烂摊子?