使用jasmine进行测试时,我收到此错误.
TypeError:moment.tz不是函数
我尝试测试的代码是
let myDate = moment().tz(undefined, vm.timeZone).format('YYYY-MM-DD');
Run Code Online (Sandbox Code Playgroud) 我的package.json看起来像这样..
"karma-phantomjs-launcher": "^0.1.4",
"karma-safari-launcher": "^0.1.1",
"karma-sinon-chai": "~0.2.0",
"karma-spec-reporter": "~0.0.16",
"mocha": "~1.20.1"
Run Code Online (Sandbox Code Playgroud)
我的npm版本是2.2.0
当我进行业力测试时,我会得到这个 - 业力开始my.conf.js
phantomjs karma-runner karma-mocha mocha-phantomjs karma-coverage
我的问题是这个问题的延伸
plunker - http://plnkr.co/edit/DiDitL?p=preview
我需要在页面加载时选择一行,我需要避免收听'ngGridEventData'
调用$ scope.gridOptions.selectRow(2,true); 由于网格尚未加载,因此控制器主体失败.
避免监听ngGridEventData是因为我需要控制器监听之前触发的事件,并根据我需要选择nggrid行.
有任何想法吗?
我的收藏看起来像这样.
var list = [{id:'12345', sequence:null}, {id:'12346', sequence:null}, {id:'12347', sequence:null}, {id:'12348', sequence:1}, {id:'12348', sequence:2}, {id:'12349', sequence:1}, {id:'12349', sequence:1}];
Run Code Online (Sandbox Code Playgroud)
我试图获得一个唯一的列表,以便具有相同id和序列的对象将只返回一个对象(我们在这里有2个 - {id:'12349',序列:1})
我的代码
var uniqueList = _.uniq(list, function(obj) {
return obj.id && obj.sequence;
});
Run Code Online (Sandbox Code Playgroud)
我们可以像这样使用lodash uniq吗?解决这个问题的方法是什么?
我有以下格式的角度引导选项卡.(参见plunker)
选择选项卡时,应该触发select函数.但奇怪的是,当页面加载时,第一个选项卡的select函数被触发.(打印选项卡选择动态标题1 onload ..)
"http://plnkr.co/edit/vyOOhCdIl7s1Wvou7Dr9?p=preview"
Run Code Online (Sandbox Code Playgroud)
angular.module('ui.bootstrap.demo', ['ui.bootstrap']);
angular.module('ui.bootstrap.demo').controller('TabsDemoCtrl', function ($scope) {
$scope.tabs = [
{ title:'Dynamic Title 1', content:'Dynamic content 1' },
{ title:'Dynamic Title 2', content:'Dynamic content 2' },
{ title:'Dynamic Title 3', content:'Dynamic content 3' }
];
$scope.tabSelect = function(title){
console.log("tab selected "+title);
};
});
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<!doctype html>
<html ng-app="ui.bootstrap.demo">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular.js"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.13.0.js"></script>
<script src="example.js"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div ng-controller="TabsDemoCtrl">
<tabset>
<tab ng-repeat="tab in tabs" heading="{{tab.title}}" active="tab.active" disable="tab.disabled" select="tabSelect(tab.title)">
{{tab.content}}
</tab>
</tabset>
</div> …
Run Code Online (Sandbox Code Playgroud)javascript twitter-bootstrap angularjs angular-ui angularjs-ng-repeat
我们有2个非常简单的SELECT语句:
SELECT value from table where date between DATE1 and DATE2
SELECT value from table where date between DATE3 and DATE4
Run Code Online (Sandbox Code Playgroud)
我们需要一种方法来编写单个SQL语句,它将获得从这两个SQL语句返回的"值"的差异.
我们尝试了以下但是没有成功:
SELECT value from table where date between DATE1 and DATE2
minus
SELECT value from table where date between DATE3 and DATE4
Run Code Online (Sandbox Code Playgroud)
任何建议都非常感谢.
我有以下查询,
在名称字段中查找标签并用空格替换它们 - 以摆脱它们.
名称字符串可以包含1到多个
标签,例如
AA aa
AA aa
AA aa
AA aa
AA AA aaaaaaaa
Run Code Online (Sandbox Code Playgroud)
... 像那样.
db.tests.find({'name':/.* .*/}).forEach(function(test){
test.name = test.name.replace(" ","");
db.tests.save(test);
});
db.tests.find({'name':/.* .*/}).forEach(function(test){
test.name = test.name.replace(" ","");
db.tests.save(test);
});
db.tests.find({'name':/.* .*/}).forEach(function(test){
test.name = test.name.replace(" ","");
db.tests.save(test);
});
Run Code Online (Sandbox Code Playgroud)
除了重复相同的查询模式之外,还有更好的解决方案来处理这种情况,从减少重复和提高性能的角度来看?
我对JS很新,并且明白我的脚本可能很糟糕,但它在Safari和Chrome中运行良好,而不是在Firefox中.
除此之外,我正在调用两个函数来隐藏和显示一个自定义的Quicktime电影控制器,在它的顶部放置一个"面具"(我知道切换将是一个更优雅的解决方案,但我无法得到这样的功能以我想要的方式工作).无论如何,这就是Javascript的样子:
function revealControls(){
document.getElementById("controlsCover");
controlsCover.style.display ="none"
}
function hideControls(){
document.getElementById("controlsCover");
controlsCover.style.display ="block"
}
Run Code Online (Sandbox Code Playgroud)
我用不同的鼠标事件调用这些函数应用于各种div,例如:
<div id = "controls" onmouseout = "hideControls()">
Run Code Online (Sandbox Code Playgroud)
Firefox告诉我
"Error: controlsCover is not defined",
Run Code Online (Sandbox Code Playgroud)
我不知道如何将元素定义为null.
任何帮助,将不胜感激.我确信这很简单 - 但我几乎没有使用Javascript的经验.然而.
如何从下面的列表菜单中排除某些国家/地区?现在我的代码将列出数据库中的所有国家/地区名称.
示例我想从列表菜单中排除阿尔巴尼亚国家/地区.如何根据这些代码实现它.
码
<?php $select_country=mysql_query("SELECT * FROM tbl_country ORDER BY country_name ASC")?>
<select name="country" onchange="return get_country(this.value);">
<option value=""><?=SELECT_COUNTRY?></option>
<? while($country=mysql_fetch_array($select_country)) {?>
<option <? if($_SESSION['getcountry']==$country['id']){ ?> selected="selected"<? }?> value="<?=$country['id']?>">
<?=$country['country_name']?></option>
<? } ?>
</select>
Run Code Online (Sandbox Code Playgroud)
Mysql的
id country_name
1 Afghanistan
2 Aland Islands
3 Albania
4 Algeria
5 American Samoa
6 Andorra
Run Code Online (Sandbox Code Playgroud) 我需要从xml文件中提取数据并绘制图形:深度与时间戳.标题应该是IFC代码.我尝试使用xmlToList和xmlTodataframe,但我没有这样做.我需要帮助.我的xml文件看起来像
<document>
<site>
<IFC_code>HONEYCR01</IFC_code>
<Latitude>41.960161</Latitude>
<Longitude>-90.470759</Longitude>
<River>Honey Creek</River>
<Road>Hwy 136, 1st Street</Road>
<Town>Charlotte</Town>
<from_sensor_to_river_bottom>9.35</from_sensor_to_river_bottom>
<Unit>foot</Unit>
</site>
<data>
<value>
<timestamp>2012-05-17 15:30:03-05</timestamp>
<depth>8.53</depth>
</value>
<value>
<timestamp>2012-05-17 14:30:06-05</timestamp>
<depth>8.50</depth>
</value>
<value>
<timestamp>2012-05-17 14:15:02-05</timestamp>
<depth>8.51</depth>
</value>
<value>
<timestamp>2012-05-17 14:00:12-05</timestamp>
<depth>8.50</depth>
</value>
<value>
<timestamp>2012-05-17 13:45:08-05</timestamp>
<depth>8.51</depth>
</value>
</data>
</document>
Run Code Online (Sandbox Code Playgroud) javascript ×6
angular-ui ×2
angularjs ×2
firefox ×1
jasmine ×1
karma-mocha ×1
karma-runner ×1
lodash ×1
momentjs ×1
mongodb ×1
mysql ×1
ng-grid ×1
nosql ×1
oracle ×1
oracle10g ×1
phantomjs ×1
php ×1
r ×1
regex ×1
select ×1
sql ×1
unique ×1
unit-testing ×1
xml ×1
xml-parsing ×1