在ngOnInit组件的方法中,@ Invput值将被绑定,因此您可以检查组件上的这些属性,但似乎没有办法检查@Output事件绑定.我希望能够知道@Output是否已连接到组件上.
(使用Angular 2 beta 2和TypeScript)
import {Component, Output, EventEmitter} from 'angular2/core';
@Component({
selector: 'sample',
template: `<p>a sample</p>`
})
export class SampleComponent {
@Output() cancel = new EventEmitter();
ngOnInit() {
// would like to check and see if cancel was used
// on the element <sample (cancel)="doSomething()"></sample>
// or not <sample></sample>
}
}
Run Code Online (Sandbox Code Playgroud) 我正在将我的遗留代码库移植到使用AngularJS 1.5推广的新组件架构.我在为更大的表单执行此操作时遇到了问题.传统上,我会附加表单验证如下:
<form name="myForm">
<input type="text" name="input1" ng-model="vm.input1" required />
<div ng-messages="myForm.input1.$error">
<div ng-message="required">Please fill out this field.</div>
</div>
<!-- many more inputs -->
</form>
Run Code Online (Sandbox Code Playgroud)
转换到组件体系结构时,我必须将表单显式传递给组件:
<form name="vm.myForm">
<my-awesome-input-component model="vm.input1" form="vm.myForm"><my-awesome-input-component>
<!-- many more inputs -->
</form>
Run Code Online (Sandbox Code Playgroud)
我想避免vm用我的表格污染.有没有更好的方法来实现表单所需的组件架构?
在尝试提高我的Gradle Android版本的性能时,我偶然发现了Gradle Daemon,并且已经在本地构建中取得了巨大的成功.
但是,当在Ubuntu 14.04上的Jenkins下运行时,构建会间歇性地失败:
Starting process 'Gradle Test Executor 2'. Working directory: /tmp/myproject/android/example Command: /usr/lib/jvm/java-8-oracle/bin/java -Djava.awt.headless=true -Djava.security.manager=worker.org.gradle.process.internal.worker.child.BootstrapSecurityManager -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -ea -cp /data/var/lib/jenkins/.gradle/caches/2.14.1/workerMain/gradle-worker.jar worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor 2'
Successfully started process 'Gradle Test Executor 2'
Daemon vm is shutting down... The daemon has exited normally or was terminated in response to a user interrupt.
Starting process 'Gradle Test Executor 3'. Working directory: /tmp/myproject/android/example Command: /usr/lib/jvm/java-8-oracle/bin/java -Djava.awt.headless=true -Djava.security.manager=worker.org.gradle.process.internal.worker.child.BootstrapSecurityManager -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -ea -cp /[...]/.gradle/caches/2.14.1/workerMain/gradle-worker.jar worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor …Run Code Online (Sandbox Code Playgroud) continuous-integration gradle jenkins android-gradle-plugin gradle-daemon
在下面的场景中传递消息的最佳方法是什么.
在成功场景中$scope.p.$save,结果包含一条message(res.message),我想在下一个视图中显示($location.path("/test/"+res.reply.Id)).没有AngularJS,我可以在URL中传递它或将其保存在会话cookie中.但是,我想AngularJS可能有更好的方法,因为没有浏览器重定向,状态应该可用.实现这一目标的最佳方法是什么?
在rootScope中设置它会在我使用浏览器后退按钮时显示它,并且消息的范围应仅用于第一次导航到新视图.
function NewCtrl(Phone, $location, $rootScope, $scope) {
$scope.p = new Phone();
$scope.save = function () {
$scope.p.$save(
{},
function (res) {
$rootScope.message = res.message **//<-- this will cause message still set when using browser back button, etc**
$location.path("/test/"+res.reply.Id); **//<-- Req: needs to pass the message to next view**
}, function (res) {
//TODO
}
);
};
}
....
PhoneApp.factory('Phone', function ($resource) {
return $resource('/api/test/:_id')
});
Run Code Online (Sandbox Code Playgroud) 我们有一个简单的Azure函数来进行DocumentDB查询.这似乎是我们第一次称之为漫长的等待完成,然后连续的呼叫非常快.
例如,我刚打开我们的应用程序,第一个函数调用需要10760毫秒,任何最终用户都明显可以注意到.在此之后,所有函数调用大约需要100毫秒进行处理,几乎察觉不到.
好像Azure函数中有一些"唤醒"循环.是否有某种方法可以最大限度地减少这种情况,或者更好的方法是将其记录在某处,以便我们能够理解这里真正发生了什么?
我有可执行文件abcd.exe(它包含/合并了许多.dll).是否可以为abcd.exe创建Azure功能并在Azure云功能中运行它?
abcd.exe应用程序:
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
**startInfo.Arguments = "/C abcd.exe";**
process.StartInfo = startInfo;
process.Start();
Run Code Online (Sandbox Code Playgroud)
该abcd.exe应用程序没有用户界面(GUI),但它是数学和科学应用,并从中内部abcd.exe合并许多.dll文件依赖.
谢谢
我正在尝试使用AngularJS的jQuery-UI选项卡.
请参阅此处的示例
问题是,jQuery("#tabs").tabs();在控制器中调用似乎与"tabbify"所需内容的"一半"挂钩.
想法?
我一直在尝试使用AngularJS在模态窗口中加载数据,但我不知道该怎么做.我还需要在单击链接时更改URL以及在模式窗口内加载数据而不是加载新页面.
我尝试过使用jQuery Facebox插件,但它似乎没有用,我也使用了twitter bootstrap模态组件.
以下是我的代码:
<div class="subnav span12" id="post-main-container" ng-controller="PostsController">
<div class="btn-group pull-left span5" id="sort-nav">
<a class="btn active">Popular</a>
<a class="btn">Recent</a>
<a class="btn">Favorite</a>
</div>
<div class="btn-group pull-right " id="view-nav">
<a class="btn" id="2col"><i class="icon-th-large"></i></a>
<a class="btn active" id="4col"><i class="icon-th"></i></a>
<a class="btn" id="6col"><i class="icon-th-list"></i></a>
</div>
<div class="btn-group pull-right">
<a id="reload" class="btn"><i class="icon-refresh"></i></a>
<a class="btn"><i class="icon-random"></i></a>
</div>
<div class="row-fluid span12" id="img-container">
<ul class="unstyled" id="image-container">
<li class="post-container box2" ng-repeat="post in posts">
<div class="post-btns" style="display:none;">
<a class="btn btn-mini" href="#">Share</a>
<a class="btn btn-mini" href="#">Add</a>
</div>
<a href="#/posts/{{post.id}}"> …Run Code Online (Sandbox Code Playgroud) 所以我设置了一个HTML5单页面应用程序,它运行良好.该页面是在/App/,当某人进入内容时,它看起来像/App/Content/1234.
一个问题:如果用户刷新页面,则服务器无法找到该URL,因为它实际上并不存在.如果我发送给他们/App/#/Content/1234,他们是金色的,但最好的方法是什么?/ App下有很多不同风格的URL.
全局捕获任何请求~/App/(.*)并将其重定向到的最佳方法是什么~/App/#/$1?
在MVC中注册的唯一路由是标准OOTB路由.
我制作了一个具有相对常见操作的张量流模型(除了一些tf.where和索引处理之外),但是用不同的输入形状(模型中有许多未定义的张量形状)来调用它.
CPU上的一切正常.但是当你使用GPU时,RAM的使用(不是GPU内存,CPU的内存)稳步增加,以填满机器的256GB并自行杀死.
在此过程中,我得到了通常的消息:
2017-03-17 16:42:22.366601: I tensorflow/core/common_runtime/gpu/pool_allocator.cc:247] PoolAllocator: After 18347 get requests, put_count=18345 evicted_count=1000 eviction_rate=0.0545108 and unsatisfied allocation rate=0.0763068
2017-03-17 16:42:22.366680: I tensorflow/core/common_runtime/gpu/pool_allocator.cc:259] Raising pool_size_limit_ from 4385 to 4823
Run Code Online (Sandbox Code Playgroud)
据我所知,GPU的某些DMA内存的池分配器.问题是它似乎永远不会满足它所获得的驱逐率,并且永远不会为自己分配更多的空间.
这是正常的行为吗?他们是控制这个的方法吗?现在,在耗尽内存之前,我无法训练模型超过1小时.
注意:我使用TF的nigthly构建版本,因为我当前模型运行所需的一些错误修正.此外,在训练期间没有添加任何操作,因为我打电话tf.get_default_graph().finalize()
编辑:尝试运行tcmalloc而不是malloc.没有帮助.我还使用了内存分析器,并没有说存在内存泄漏,tcmalloc的内存使用率稳定在500MB,即使内存使用率top更高且程序最终运行OOM.那么为什么tcmalloc剖析器不同意我看到的内存使用情况top呢?
编辑2:重新编译TF与改变硬编码参数,使其"工作".看到这里