我正在使用AWS SDK for Node.js在s3上创建文件夹或密钥.我在谷歌搜索,但我一无所获.有谁知道我如何使用AWS SDK for Node.js在我的桶下创建一个文件夹?以及如何检查您的存储桶中是否存在此文件夹?
如果使用console.aws.amazon.com
,您可以轻松地在存储桶中创建一个文件夹.似乎我没弄清楚如何使用AWS SDK for Node.js创建它?
有没有办法找到序数尺度的倒置?
我在x轴上使用字符串值,这是使用序数比例而我在鼠标移动时我想找到x轴的反转以找到鼠标位置的哪个字符串?
有没有办法找到这个?
var barLabels = dataset.map(function(datum) {
return datum.image;
});
console.log(barLabels);
var imageScale = d3.scale.ordinal()
.domain(barLabels)
.rangeRoundBands([0, w], 0.1);
// divides bands equally among total width, with 10% spacing.
console.log("imageScale....................");
console.log(imageScale.domain());
.
.
var xPos = d3.mouse(this)[0];
xScale.invert(xPos);
Run Code Online (Sandbox Code Playgroud) 我刚刚开始使用Angular,所以这可能是一个常见的新手错误,但我正在尝试实现以下url格式:
http://myapp.localhost/index.html#!/about
Run Code Online (Sandbox Code Playgroud)
我认为应该是Angular的默认值?
这是我的配置:
angular.module('App', []).config(function($routeProvider, $locationProvider, VIEWS_ROOT) {
$locationProvider.html5Mode(false);
$locationProvider.hashPrefix = '!';
// Routing
$routeProvider.when('/', {templateUrl: './welcome.html', controller: 'WelcomeController'});
$routeProvider.when('/about', {templateUrl: './about.html', controller: 'AboutController'});
})
.run(function($rootScope) {
//...
});
Run Code Online (Sandbox Code Playgroud)
在我的HTML中,我有一个简单的锚,如下所示:
<a href="#!/about">About</a>
Run Code Online (Sandbox Code Playgroud)
但是,当我单击该锚点时,生成的结果URL是:
http://myapp.localhost/index.html#/!/about
Run Code Online (Sandbox Code Playgroud)
这显然无法匹配我的任何路线...有点难以理解这里发生的事情,或者我做错了什么.我在vhost下运行我的本地Apache实例.mod_rewrite没有任何进展 - 所以看起来Angular正在这样做.
请考虑以下示例:
<html>
<body>
<script type="text/javascript">
var str="filename.jpg";
var pattOne = new RegExp('\.[^\.]*$');
var pattTwo = new RegExp('(\.[^\.]*$)');
var pattThree = new RegExp('(\.[^\.]*$)', 'g');
document.write(str.match(pattOne));
document.write('<br>');
document.write(str.match(pattTwo));
document.write('<br>');
document.write(str.match(pattThree));
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
结果如下:
.jpg
.jpg,.jpg
.jpg
Run Code Online (Sandbox Code Playgroud)
我期待这个结果:
.jpg
.jpg
.jpg
Run Code Online (Sandbox Code Playgroud)
为什么在正则表达式周围放置括号会改变结果?为什么使用'g'修饰符会再次改变结果?
我有一个共享函数,它返回我的AngularJS应用程序中最顶层元素(文档)的范围.
function topScope() {
return angular.element(document).scope();
}
Run Code Online (Sandbox Code Playgroud)
这始终有效,我始终保证可以访问应用程序中的任何子范围(无论是在控制器内还是指令内).
这是我将用它的一个例子:
topScope().$emit('pageReady');
Run Code Online (Sandbox Code Playgroud)
现在我注意到$ rootScope的工作方式也一样.
$rootScope.$emit('pageReady');
Run Code Online (Sandbox Code Playgroud)
哪个也有效并达到同样的效果.但由于$ rootScope设计是"$范围现成的"范围则没有这仍然意味着它实际上是在页面的最上面的范围(创建将继承它的方法和属性的任何范围)?因此作为附加到文档节点的范围对象的父级?
我已经浏览了几个小时的类似问题,但没有想出任何完全匹配的东西.我想要做的是通过数据绑定到我的数据中的true/false值自动检查复选框.我可以让项目名称加载没有问题,我甚至可以稍后拉取复选框值以保存到服务器,但我无法获得正确加载的初始值.
这是一个简化的例子,显示了根本问题; HTML:
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js"></script>
<script src="shoppingListNg.js"></script>
<body ng-app>
<div ng-controller="ShoppingListCtrl">
<table>
<tr ng-repeat="item in shoppingList">
<td>
<div>{{item.text}}</div>
</td>
<td>
<input type="checkbox" ng-model="item.isGotten" />
</td>
</tr>
</table>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
这是Javascript:
function ShoppingListCtrl($scope) {
$scope.shoppingList = [
{
"text": "V8 fusion",
"isGotten": "true"
},
{
"text": "Whole milk container",
"isGotten": "false"
},
{
"text": "Protein bars",
"isGotten": "true"
}
];
};
Run Code Online (Sandbox Code Playgroud)
知道为什么我不能让那些复选框尊重模型中的"true"和"false"值吗?每当页面加载时,它们总是显示未选中状态.我是否需要使用ng-checked或其他指令?
我正在尝试编写一个可在许多场景下工作的添加功能.
add(2,2,2) //6
add(2,2,2,2) //8
add(2)(2)(2) // 6
add(2)(2)(2,2).value() //8
add(2,2)(2) + 2 //8
add(2).add(2) //4
add(2,2,2).add(2).add(2,2).value() //12
add(2,2,2).add(2).value() //8
Run Code Online (Sandbox Code Playgroud)
这是我到目前为止:
function add(){
var sum = 0;
for( var i in arguments ){
sum += arguments[i];
}
var ret = add.bind(null, sum);
ret.value = function () {
return sum;
}
ret.add = function () {
for( var i in arguments ){
sum += arguments[i];
}
return sum;
}
ret.valueOf = function(){ return sum; };
return ret;
}
console.log(add(2,2,2));
console.log(add(2,2,2,2));
console.log(add(2)(2)(2)); …
Run Code Online (Sandbox Code Playgroud)我正在经历创建指令的过程.经历了一些起伏后,我完成了创建指令(widget)并完成指令将采用的各种属性.
我使用了各种可用的选项,如属性,绑定,评估,表达等.
我想的是,如果你想创建一个通用组件,你永远不会告诉人们如何将值传递给组件.
这是一个例子......
你正在创建一个新的元素组件..说
<hello name="__ARGUMENT__"></hello>
Run Code Online (Sandbox Code Playgroud)
hello的name属性是其中唯一的变量.如果你向公众公开......这些是人们可能使用这个组件的可能场景.
情况1 :
<hello name="angular"></hello>
Run Code Online (Sandbox Code Playgroud)
案例2:
<hello name="{{name}}"></hello>
Run Code Online (Sandbox Code Playgroud)
案例3:
<div ng-repeat="name in names">
<hello name="name"></hello>
</div>
Run Code Online (Sandbox Code Playgroud)
现在..针对不同的场景..我已经了解了提供的各种选项.我想不出一个你想要'属性'的场景,因为它简单地直接将值从组件替换到模板.
在您的指令定义中,如果您将名称定义为'evaluate'而不是'attribute'
如果属性:
<hello name="angular"></hello>
Run Code Online (Sandbox Code Playgroud)
如果评估:
<hello name="'angular'"></hello>
Run Code Online (Sandbox Code Playgroud)
请注意额外的单引号..
所以据我所知,评估涵盖了什么属性.并且,使用evaluate似乎是一个更好的选择,而不仅仅是属性,因为它涵盖了更多的场景!
如果有人能够解释为什么属性存在于第一位?更多选择=更多混乱.. :)
我是AngularJS的新手,并且构建了一个与服务器交互的应用程序.服务器有一个REST API,但是使用纯文本响应某些方法,而使用JSON响应其他方法.我已经使用AngularJS的$resource
服务实现了一个简单的http请求方法.
但是,当服务器响应是纯文本时,AngularJS中的响应是一个对象,响应字中的每个字符都有一个条目.我怎样才能解决这个问题(以一种好的方式)?理想情况下,我希望能够告诉我的服务何时期望纯文本以及何时期望JSON,并在两种情况下获得格式良好的响应.
有时,200 ok
即使出现错误,我正在使用的API也会返回.响应JSON对象将类似于:
{
error: true
}
Run Code Online (Sandbox Code Playgroud)
我已经构建了一个$ http response
拦截器,只是检查这个错误并拒绝它.我希望它然后跳进我的responseError
功能:
$httpProvider.interceptors.push(function($q) {
return {
response: function (response) {
if (response.data.error) {
// There has been an error, reject this response
return $q.reject(response);
}
return response;
},
responseError: function(rejection) {
// Display an error message to the user
...
return $q.reject(rejection);
}
}
});
Run Code Online (Sandbox Code Playgroud)
问题是,即使在拒绝响应之后,我的responseError
函数也没有被调用.它被调用500
错误等,所以我知道它正在工作.我希望拒绝做同样的事情.
来自文档:
responseError: interceptor gets called when a previous interceptor threw an error or resolved with a …
Run Code Online (Sandbox Code Playgroud)