我怎样才能将这样的数组转换为对象?
[128] => Array
(
[status] => Figure A.
Facebook's horizontal scrollbars showing up on a 1024x768 screen resolution.
)
[129] => Array
(
[status] => The other day at work, I had some spare time
)
)
我来这个:
(defn string->integer [str & [base]] (Integer/parseInt str (if (nil? base) 10 base))) (string->integer "10") (string->integer "FF" 16)
但它必须是一个更好的方法来做到这一点.
我在https://github.com/aikiframework/json上有一个回购.在我的本地副本上,我使用该命令添加了一个子模块
git submodule add git@github.com:jcubic/json-rpc.git json-rpc
Run Code Online (Sandbox Code Playgroud)
然后我做了一个提交和推送,更改出现在GitHub上(我可以点击它).但是当我克隆回购时
git clone https://github.com/aikiframework/json.git
Run Code Online (Sandbox Code Playgroud)
子模块文件夹json-rpc为空.
我在这里错过了什么?我忘记了什么吗?为什么那个文件夹是空的?
尝试过滤掉具有非空属性的项目因此:
var details = [{name:'Bill', shortDescription: null}, {name:'Sally', shortDescription: 'A girl'}]
Run Code Online (Sandbox Code Playgroud)
我想只展示一个李; 莎莉的那一个.这是我试过没有成功的
<ul>
<li ng-repeat="detail in details | filter:{shortDescription:'!'}">
<p>{{detail.shortDescription}}</p>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
知道如何在不创建自定义过滤器的情况下做到这一点吗?或者即便如此,自定义过滤器会是什么样子?
我已经安装了grunt使用grunt,我无法将其删除.
我试过了:
$ sudo npm uninstall grunt
Run Code Online (Sandbox Code Playgroud)
但它给了警告:
npm WARN uninstall not installed in /home/kuba/projects/node_modules: "grunt-cli"
Run Code Online (Sandbox Code Playgroud)
我也试过rm,删除和取消链接.和sudo npm install grunt选项,它给:
npm WARN uninstall not installed in /usr/lib/node_modules: "grunt"
Run Code Online (Sandbox Code Playgroud)
但我仍然可以WARN从命令行调用.
编辑:
$ whereis grunt
grunt: /usr/local/bin/grunt
$ file /usr/local/bin/grunt
/usr/local/bin/grunt: symbolic link to `../lib/node_modules/grunt/bin/grunt'
$ ls /usr/local/lib/node_modules
grunt jshint
$ ls /usr/lib/node_modules
bower csslint devtools-terminal npm plato
Run Code Online (Sandbox Code Playgroud)
为什么我有2个目录与npm?删除它是否安全?
我正在测试路由器并且有两个功能,我需要测试第一个函数是否被调用而第二个函数没有被调用.有方法,toHaveBeenCalled但没有方法来测试函数是否被调用.我怎么测试呢?
我有这样的代码:
var args, controller, router;
beforeEach(function() {
controller = {
foo: function(name, id) {
args = [].slice.call(arguments);
},
bar: function(name) {
}
};
spyOn(controller, "foo").and.callThrough();
spyOn(controller, "bar").and.callThrough();
router = new route();
router.match('/foo/bar/{{id}}--{{name}}', controller.foo);
router.match('/foo/baz/{{id}}--{{name}}', controller.bar);
router.exec('/foo/bar/10--hello');
});
it('foo route shuld be called', function() {
expect(controller.foo).toHaveBeenCalled();
});
it('bar route shoud not be called', function() {
// how to test if bar was not called?
});
Run Code Online (Sandbox Code Playgroud) 我希望能够在不改变状态的情况下更改地址'URL,以防止重新渲染.从我的搜索,ui-router目前不提供这个,但从$location.pathanuglar做.
所以,当然,我想用来$state.get(stateName)获取状态的URL,这样我就不会手动输入URL.
我有两个问题:
$state.get(stateName)仅返回相对路径.我怎样才能获得绝对路径?例如,如果我有一个名为user.home.viewwith 的状态user.home,我将我的状态定义为
'user': {
abstract: true,
url: '^/users/'
},
'user.home': {
url: ''
},
'user.home.view': {
url: ':id/'
}
Run Code Online (Sandbox Code Playgroud)
所以现在,$state.get(user.home.view).url回归:id/.我怎样才能获得完整的URL(即/users/5/)?
我想获得当前日期,但时间应该是 00:00:00.000
我试过这个:
var m = moment();
m.set({hour:0,minute:0,second:0,millisecond:0});
console.log(m.toISOString());
Run Code Online (Sandbox Code Playgroud)
但我有:2016-01-12T23:00:00.000Z为什么23而不是00?
我找不到关于Angular.js的这些信息,我注意到在我工作的时候,这两个值的工作方式不同.有什么不同?
.directive('foo', function() {
return {
scope: true
};
});
.directive('foo', function() {
return {
scope: {}
};
});
Run Code Online (Sandbox Code Playgroud)