首先,我是角单元测试的新手。我想对以下方法进行单元测试,该方法将从我的数据中删除一条记录。方法是:
//Confirm Button for deletion
confirm(name: string, id: any) {
this.confirmationService.confirm({
message: 'Are you sure you want to remove ' + name + ' from your list of Supporting Staff?',
accept: () => {
const index: number = this.data.indexOf(id);
if (index !== -1) {
this.data.splice(index,1);
this.totalResults = this.data.length;
this.updateVisibility();
this.alertMessage = { severity: 'success', summary: 'SUCCESSFUL REMOVAL', detail: 'You have successfully removed '+name+' from your Supporting Staff List.' };
this.alertMessagesSrv.pushAlert(this.alertMessage);
}
},
reject: () => {
}
});
}
Run Code Online (Sandbox Code Playgroud)
如您所见,我正在从PRIME …
我正在使用 Angular 5,并尝试将字符串转换为日期。在 Chrome 中工作正常,但在 Internet Explorer 11 中,我收到无效日期的错误。我尝试了多种方法,但都没有成功。我也遵循此处提供的解决方案 解决方案提供我作为输入的字符串是 '2018-04-23 15:21:15 +0300' (value),我使用以下代码:
var a = new Date(value);
Run Code Online (Sandbox Code Playgroud)
我还尝试了以下方法:
var a = new Date (new Date(value));
Run Code Online (Sandbox Code Playgroud) 我正在声明一种新的内存类型,然后使用一个函数来更新它.当我向列表中添加值时,程序编译并正常工作,但如果我的列表为空,则会出现错误"函数中的非详尽模式update".这是我的代码,如果你能帮助我:
type Name = [Char]
type Memory = [(Name,Integer)]
update :: Name ->Integer -> Memory -> Memory
update n x (h:t)
|(fst h==n) =(n,x):t
|((h:t) == []) = (n,x):[]
|(fst t==x) = h:(n,t)
|(t==[]) = h:(n,x):[]
|otherwise = h:update n x t
Run Code Online (Sandbox Code Playgroud) angular ×2
angular5 ×1
date ×1
haskell ×1
invalidation ×1
primeng ×1
service ×1
unit-testing ×1