我只是想知道如何测试这个handleAddClientBroadcast事件?
我有这样的导航服务:
angular.module("ruleManagement.services")
.factory('navigationService', function ($rootScope) {
var navigationService = {};
navigationService.prepForBroadcast = function() {
this.broadCastIsAddClientItem();
};
navigationService.broadCastIsAddClientItem = function() {
$rootScope.$broadcast('handleAddClientBroadcast');
};
return navigationService;
});
Run Code Online (Sandbox Code Playgroud)
我把这个导航服务注入到我的中,clientsCtrl然后抓住handleAddClientBroadcast这样的:
$scope.$on('handleAddClientBroadcast', function () {
$scope.clientModel = {
id: 0,
name: "",
description: "",
rules: []
};
var lastClient = _.findLast($scope.clients);
if (typeof lastClient == 'undefined' || lastClient == null) {
lastClient = $scope.clientModel;
}
$scope.clientModel.id = lastClient.id + 1;
$scope.clients.push($scope.clientModel);
});
Run Code Online (Sandbox Code Playgroud)
谢谢.
我正在使用Jenkins和Git插件,它提供以下环境变量:
- GIT_COMMIT:当前的SHA
- GIT_BRANCH:当前正在使用的分支的名称,例如"master"或"origin/foo"
- GIT_PREVIOUS_COMMIT:来自同一分支的先前构建的提交的SHA(分支中第一个构建的当前SHA)
- GIT_URL:存储库远程URL
- GIT_URL_N:存在多个远程URL时的存储库远程URL,例如GIT_URL_1,GIT_URL_2
- GIT_AUTHOR_EMAIL:提交者/作者电子邮件
- GIT_COMMITTER_EMAIL:提交者/作者电子邮件
使用版本号插件,我有一个${GIT_COMMIT}按预期读取的变量.
问题是,它是完整的32(?)字符SHA哈希.我想把它的一个子串.有没有办法在Jenkins中获取环境变量的子字符串?
我正在开发一个网站,无处不在我有这个烦人的问题...我想知道其他网站怎么没有这个问题...任何建议?stackoverflow有这个问题,因为我看到...
http://inath.gr/这个网站例如在顶部菜单虽然它有<a>标签没有矩形围绕它选择某种方式..
我有脚本调用不同的URL,具体取决于它们是由我的在线站点(发布)还是我的离线本地主机(开发)处理的.我想找到一个快速的方法来找到哪个是哪个.
我可以想出一些笨重的方法来做到这一点,但是有一种明确,快速,优雅的方法吗?就像是if(is_offline()) { ... }
php development-environment localhost production-environment
有没有办法从Eclipse的实例中查看用于Java虚拟机的环境变量?
换句话说,我该如何检查这个Eclipse实例正在使用哪些环境变量?
我有一个便携式设置,我希望看到一切正常,我期待...
有没有办法避免parent::PHP类中的静态访问器,或者这是一个使用时间@SuppressWarnings(StaticAccess)?
同样,似乎这个StaticAccess警告在可疑的地方突然出现.例如,异常处理 - 当我throw new Exception(...),PHPMD抱怨静态访问时.但是......没有其他方法可以做到(我已经发现)所以我有更多的警告抑制器比我想要的更多.这是正常的吗?
编辑
根据要求,这是一个例子 - 它非常简单:
class aaa {
private $someReasonForAnException = true;
public function __construct() {
echo 'AAA<br>';
if ($this->someReasonForAnException) {
throw new Exception("Something happened that's worth noticing!");
}
}
}
class bbb extends aaa {
public function __construct() {
echo 'BBB<br>';
parent::__construct();
}
}
$BBB = new bbb();
Run Code Online (Sandbox Code Playgroud)
PHPMD将报告上述两个错误:StaticAccess错误Exception,以及调用StaticAccess错误parent::__construct().
为了避免这种情况,我必须注意两个类@SuppressWarnings,这看起来很笨,并且也不会显示"真正的"静态访问问题.
我开始玩Jade,我遇到了这个奇怪的问题.我确定这是愚蠢的,但我已经尝试了一个小时没有成功.
我有一个包含组的对象,每个组包含项目.所以,有一个ng-repeat嵌套在另一个里面.
ul.page-sidebar-menu(ng-repeat="group in menuItems")
li(ng-class="group.groupStyle")
a(href="{{group.target}}")
i(ng-class="group.iconStyle")
span.title {{group.name}}
span(ng-class="group.spanStyle")
ul.sub-menu(ng-repeat="item in group.items")
li
a(href="{{item.target}}") {{item.name}}
Run Code Online (Sandbox Code Playgroud)
对象源是这样的:
[
{
name: "Inicio",
target: "/",
groupStyle: {
start: "start",
active: "active"
},
spanStyle: {
selected: "selected"
},
iconStyle: "icon-home"
},
{
name: "Catalogo",
target: "javascript:;",
groupStyle: { },
spanStyle: {
arrow: "arrow"
},
iconStyle: "icon-book",
items: [
{ name: "Clientes", target: "view1" },
{ name: "Rutas", target: "view1" },
{ name: "Transportistas", target: "view1" }
]
},
{
name: …Run Code Online (Sandbox Code Playgroud) 请帮帮我!
我已经创建了一个EmployeeTest写入Employee类的类,但是在我完成它之前会发生这个错误.我在这个项目之前编写了类似的项目,它运行没有错误.这是一个非常简单的类,如下所示.
这是错误消息:
initialization ERROR : No runnable methods
-No runnable methods
-java.lang.Exception
-at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
Run Code Online (Sandbox Code Playgroud)
这是EmployeeTest班级:
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
public class EmployeeTest {
Employee employee;
public EmployeeTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
employee = new Employee("Austin", "Powers", 70000.00);
}
public void testGetName(){
String expected = "Austin Powers";
String actual = …Run Code Online (Sandbox Code Playgroud) 我想从固定基数计算"我必须使用的数字的哪个幂",例如2.
我想找到一个数字的下一个(整数)幂,例如2 ^ 3 = 8 ==> get2Power 8 ==> 3.
这很简单,但 get2Power 10 ==> 4 由于2^3=8下限和2^4=16上限我想返回上限,4.
通过简单的数学运算,我知道我可以用一些对数函数来计算功率,即log(x) / log(2)得到一个Double.但我希望有下一个Integer.
我的方法看起来像
get2Power :: Integer -> Integer
get2Power x
| x <= 0 = -1
| otherwise = round (log(x) / log (2))
Run Code Online (Sandbox Code Playgroud)
失败的原因是类型之间缺少一些转换.错误消息无助于了解我所缺少的内容.
有人可以帮我解决如何将Double结果转换为Integer/int的问题吗?
我必须更改XML的"未知"内容.结构和内容本身是有效的.原版的
<blabla foo="bar">
<aa>asas</aa>
<ff>
<cc>
<dd />
</cc>
</ff>
<gg attr2="2">
</gg>
...
...
</blabla>
Run Code Online (Sandbox Code Playgroud)
变
<blabla foo="bar">
<magic>
<aa>asas</aa>
<ff>
<cc>
<dd />
</cc>
</ff>
<gg attr2="2">
</gg>
...
...
</magic>
</blabla>
Run Code Online (Sandbox Code Playgroud)
因此,在文档根节点(document.documentElement)下直接添加子项并在其下"推送""原始"子项.这里必须用普通的javascript(ecmascript)来完成.
现在的想法是
// Get the root node
RootNode = mymagicdoc.documentElement;
// Create new magic element (that will contain contents of original root node)
var magicContainer = mymagicdoc.createElement("magic");
// Copy all root node children (and their sub tree - deep copy) to magic node
/* ????? here …Run Code Online (Sandbox Code Playgroud)