草庐IT

angularjs-jasmine-matchers

全部标签

javascript - AngularJS 如何使用过滤器延迟加载图像

我正在开发一个Angular应用程序,其中主页加载1000张图像,但用户一次只能查看20张。我还将在我的列表中设置多个过滤器,以便可以根据不同的标准对其进行过滤和排序。我试过了http://binarymuse.github.io/ngInfiniteScroll/#和http://ngscroller.herokuapp.com/但似乎都没有那么好用。Ngscroller确实可以工作,但是当我尝试应用我的过滤器时它会中断。我也更喜欢这个,因为它不需要我包含jquery。是否有任何简单的指令可以满足我的需要?我正在尝试加快我的网页速度,但我不想重新发明轮子,如果已经有一些东西可以做到这

javascript - 隔离范围 "="绑定(bind)和点符号 AngularJS

如何在带点符号的独立作用域中使用嵌套属性创建双向绑定(bind)。我认为'myObject.data':"=data"会工作,但事实并非如此。我不想链接myObject对象中的所有内容。我知道我可以做一些观察,但'myObject.data'看起来更干净。.directive("myDirective",[function(){return{restrict:"E",scope:{'myObject.data':"=data"},link:function(scope,element,attrs){scope.myObject={data:"myValue"};}};}])

javascript - AngularJS $resource 响应作为字符数组从 ExpressJS 返回

我有一个expressjsapi,我的angularJS$resource对象与之通信。我已经用postman(一个用于测试RESTapi的chrome工具)发送了一个post请求,响应中的原始数据是:“已提交”。标题:Connection→keep-aliveContent-Length→9Content-Type→text/html;charset=utf-8Date→Sun,02Feb201412:02:20GMTX-Powered-By→Express当我以angular注销我的回复时,我得到以下信息:Resource0:"S"1:"u"2:"b"3:"m"4:"i"5:"t"

javascript - Jasmine 2.0 TeamCity 记者

使用teamcity、requirejs和运行phantomjs.exe的jasmine1.3构建了一个有效的CI,我正在尝试将jasmine升级到2.0版。在这篇精彩的文章之后,我得到了一个基本的htmlspecrunner页面。(Jasmine现在加载到windows.onload,https://stackoverflow.com/a/20851265/564577)现在我正在尝试让teamcity-reporter工作。(来自测试框架下的插件页面,http://confluence.jetbrains.com/display/TW/TeamCity+Plugins#)它依赖于j

javascript - AngularJS 最佳实践 - 风格指南

我正在尝试使用google-styleguide网站上定义的一些Angular最佳实践:https://google-styleguide.googlecode.com/svn/trunk/angularjs-google-style.html但目前我正在努力解决一些问题。在我使用这个样式指南之前,我有$scope变量可以用来对一个变量执行$watch。app.controller('myController',['$scope',function($scope){$scope.$watch('myVariable',function(val){alert("I'mchanged");

javascript - Uncaught Error : [$injector:unpr] Unknown provider Ionic Framework/AngularJS

在localstoragetutorialontheIonicblog之后,我试图在我的Ionic应用程序运行时设置/获取localStorage值,但我收到错误消息:UncaughtError:[$injector:unpr]Unknownprovider:$localstorageProvider我的app.js代码:angular.module('starter',['ionic','starter.controllers','starter.services']).run(function($ionicPlatform,$localstorage){$ionicPlatform

javascript - 一个指令可以在 angularjs 中有不同的名称吗?

我有两个具有相同功能的指令,如下所示。angular.module('ui.directives',[]).directive('uiFoo',function(){return{restrict:'EAC',link:function($scope,element,attrs){//todofunctionalityelement.append("testcontent");}};}).directive('uiFoo1',function(){return{restrict:'EAC',link:function($scope,element,attrs){//todofuncti

javascript - AngularJS 指令 $watch 双向绑定(bind)

我试图通过双向数据绑定(bind)属性('=')区分内部更改和外部更改。换句话说:如果更改是内部的(即范围变量在Controller或链接函数中更改),我不想$watch触发该值。这里有一些代码可以说明我的问题:HTMLJavascriptapp.directive('mydemo',function(){return{restrict:'E',scope:{value:"="},template:"ClicktochangevalueattributeValue:{{value}}",link:function(scope,elm){scope.$watch('value',func

javascript - 使用 Jasmine 对 $modal 进行单元测试

我有一个带有Controller的Angular应用程序,它在函数调用期间显示Angular-Strap模态窗口。它在Chrome中正常运行,但我无法进行有效的单元测试。App模块和FooController:varapp=angular.module("app",["mgcrea.ngStrap"]);app.controller("FooController",function($scope,$modal){varfooModal=$modal({title:'Foo',content:'Bar',show:false,html:true,backdrop:'static',pla

javascript - 使用 Jasmine 测试异步回调

我正在使用Jasmine2.1。我正在尝试使用Jasmine2.1来测试模块。我的模块之一具有异步执行代码的功能。当应用程序完成执行时,我需要测试函数的结果。有没有办法做到这一点?目前,我的模块看起来像这样:varotherModule=require('otherModule');functionMyModule(){}MyModule.prototype.state='';MyModule.prototype.execute=function(callback){try{this.state='Executing';varm=newotherModule.Execute(funct