我在angularjs中编写Web应用程序并使用角度材料(不确定这是否与问题相关)和ngMessages为用户提供无效输入的反馈.
通常,为了验证所提供的指令,我可以通过类似于以下的方式进行验证:
<md-input-container>
<input required name="myInput" ng-model="someModel">
<div ng-messages="formName.myInput.$error">
<div ng-message="required">This field is required.</div>
</div>
</md-input-container>
Run Code Online (Sandbox Code Playgroud)
但是如果我创建了自己的自定义指令......
moduleName.directive('ngCustomdir', function(){
return {
restrict: 'A',
require: 'ngModel',
link: function($scope, $element, $attrs, ngModel){
//do some validation
return validation; //<--true or false based on validation
}
};
}
Run Code Online (Sandbox Code Playgroud)
并将其包含在我的输入中......
<input required ng-customdir name="myInput" ng-model="someModel">
Run Code Online (Sandbox Code Playgroud)
我知道它会验证输入,因为如果根据我的自定义指令验证输入无效,则字段变为红色且$ invalid值设置为true,但我不知道如何根据何时使用ngMessages显示消息有时候是这样的.
<div ng-messages="formName.myInput.$error">
<div ng-message="required">This field is required.</div>
<div ng-message="customdir">This is what I need to appear.</div>
</div>
Run Code Online (Sandbox Code Playgroud)
当我的自定义指令验证无效时,我似乎无法显示消息.我该怎么做呢?我在这里先向您的帮助表示感谢.
我有一个CronJob在 Kubernetes 的容器中运行一个进程。
此过程需要一个由--since和--until标志定义的时间窗口。这个时间窗口需要在容器启动时间(cron 被触发时)定义,并且是当前时间的函数。运行此过程的示例是:
$ my-process --since=$(date -v -1H +"%Y-%m-%dT%H:%M:%SZ") --until=$(date -v +1H +"%Y-%m-%dT%H:%M:%SZ")
Run Code Online (Sandbox Code Playgroud)
所以对于上面的例子,我希望时间窗口是从 1 小时前到未来 1 小时。Kubernetes 有没有办法将格式化的日期时间作为命令参数传递给进程?
我正在尝试做的一个例子是以下配置:
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: my-process
spec:
schedule: "*/2 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: my-process
image: my-image
args:
- my-process
- --since=$(date -v -1H +"%Y-%m-%dT%H:%M:%SZ")
- --until=$(date -v +1H +"%Y-%m-%dT%H:%M:%SZ")
Run Code Online (Sandbox Code Playgroud)
这样做时,文字字符串"$(date -v -1H +"%Y-%m-%dT%H:%M:%SZ")"将作为--since标志传入。
这样的事情可能吗?如果是这样,我该怎么做?