草庐IT

angularJS-karma-jasmine

全部标签

javascript - 具有 0.01 个步骤的数字输入为 angularjs 中的某些值提供未定义

在angularjs(1.6.1)中使用该类型的输入,为9.03到9.05之间的值提供undefined。使用其他值时会重现此问题,其中包括9.62、9.63、17.31。这fiddle重现问题。只需在数字输入中单击向上即可。在linuxmint18下的firefox和chromium上测试。它似乎链接到"step"属性。如果设置为"0.001"就没有问题。但是我在这个应用程序中威胁金钱,所以需要2位小数。注意:如果值最初通过data-numeric-value设置为9.03,则它不是未定义.这个错误有什么解决方法吗?编辑已更新fiddle显示step="0.01"与step="0.0

javascript - 如何在angularjs中获取周明智的开始和结束日期

在我使用这个npm中的angularjs-DatePicker之前.在这里,我可以从日期选择器中选择日期。但现在我必须将字段设置为FromDate和ToDate,这意味着周StartDate和EndDate应该在该周的任何日期选择时显示。ex:就像在Calender01-08-2017中一样,从周二开始,因此,每当从01到05选择任何日期时,两个字段都应显示为01和todateastodateastodateas06,并且每当用户选择31时-07-2017这两个字段应显示为7月30日和31日。我有一个想法从FromDateCalender控制onchange事件在DotNet中实现To

javascript - Jasmine - 如何模拟 history.pushState 和假事件发射?

在history.pushState的帮助下,我正在编写一个支持浏览器导航的库并且还捕获了popstateevent在浏览器中进行导航时进行通信。因为我正在尝试写Jasmine测试这个库,我想知道如何模拟history.pushState并且还伪造了popstate的发射来自window的信号?以下代码片段应该可以说明问题:库代码:varlib=(function(){functionnavigate(path){history.pushState(null,null,path);}functiononPopState(event){if(lib.callback){lib.callb

javascript - Jasmine 与 coffeescript 共享规范范围问题

我试图通过提取共享示例来DRY一些jasmine测试。@sharedExamplesForThing=(thing)->beforeEach->@thingy=newthingit"isneat",->expect(@thingy.neat).toBeTruthy()describe"widgetwithsharedbehavior",->sharedExamplesForThing(->newWidget)当一切都在一个文件中定义时,这会很好地工作。当我尝试将sharedExamples移动到单独的文件时,会出现我遇到的问题。我得到Can'tfindvariable:sharedEx

javascript - 在 AngularJS 中使用 $controller 时如何消除缩小错误

angular.module('mainApp').controller('dynamicRouteController',['$scope','$controller','$routeParams',function($scope,$controller,$routeParams){if(/^\d+$/.test($routeParams.pageOrName)){$scope.controller=$controller('thisController',{$scope:$scope}).constructor;$scope.templateUrl='/www/thisPage';

javascript - Angularjs 为范围使用自定义插值符号

我目前有一个underscore.js模板,我也想将它与angular一起使用,并且仍然能够与下划线一起使用。我想知道是否可以使用指令更改特定范围的插值开始和结束符号,如下所示:angular.directive('underscoreTemplate',function($parse,$compile,$interpolateProvider,$interpolate){return{restrict:"E",replace:false,link:function(scope,element,attrs){$interpolateProvider.startSymbol("");va

javascript - 带有 angularjs $http.post 请求的 Paypal

这是购买东西的标准Paypal表格。我不想要这种形式,我想用angularJS做这个:Buythis.checkOut=function(){vardata={...//handlealldata};$http.post('https://www.paypal.com/cgi-bin/webscr',data).success(function(data){console.log("success"+data);}).error(function(data){console.log("error"+data);});}这给了我一个错误:XMLHttpRequestcannotloadh

javascript - AngularJS如何防止重复的http请求?

在过去的一天里,我一直在为一些奇怪的情况而苦苦挣扎。发生的情况是,对于远程服务器上API的http请求,偶尔会发送重复的请求。谁能提供有关如何避免这些重复请求的帮助?这是我在工厂中使用的函数示例:factory.getAllConsultedClientsLogs=function(oParams){vardeferred=$q.defer();$http.post('url/to/api',oParams).success(function(response){deferred.resolve(response);}).error(function(){deferred.reject

javascript - Angularjs datepicker popup bootstrap-ui 在 View 中不起作用

我是一个angularjs和bootstrapui新手!我的日期选择器弹出窗口在我包含的View中不起作用。如果它在View之外,它会起作用。即如此处所示任何帮助将不胜感激。但是,因为我使用的是ngRoute方法,所以我需要在部分html中编写我的View并包含在主index.html中。内联日历不显示,弹出日历也不显示。我无法找出问题所在,但我认为date-picker.html无法引用我的index.html中的脚本和样式。我在日期选择器hmtl中还有其他包含的Pane,它引用了index.html中的脚本和css。任何帮助将不胜感激。下面是代码:**index.html**Som

javascript - Karma Require.js——改变目录结构正在杀死一切

几天来,我一直在尝试设置karma以与Require.js一起工作(然后再将require与angular一起使用),这令人非常沮丧。这是我的文件树在这个例子中的样子:$tree.|--public||--index.html||--src||--app.js|`--main.js|--config||--karma.conf.js|--lib||--jquery.js||--require.js|`--underscore.js|--src||--app.js|`--main.js`--test|--appSpec.js`--test-main.js注意事项:我正在处理的这个存储库是