草庐IT

working-with-models

全部标签

javascript - Angular JS : binding in ng-show not working

我有一个指令和一个Controller:app.directive('responseBox',function(){return{restrict:'E',transclude:true,templateUrl:'responseBox.html',link:function(scope,element,attrs){element.bind("click",function(){scope.toggle();})}}});和一个Controller:app.controller('responseBoxCtrl',function($scope){$scope.opened=fal

javascript - 引用错误 : Can't find variable: jQuery with Poltergeist/Capybara

我想做什么我正在尝试使用带有poltergeist的capybara通过此URL登录亚马逊......https://developer.amazon.com/rp/sales.html很简单,除了当我尝试提交表单时,出现错误...ReferenceError:找不到变量:jQuery...但是,jQuery的源代码在页面上并且应该已经加载。我用来登录的代码是这样的...visit"https://developer.amazon.com/rp/sales.html"fill_in('ap_email',with:user)fill_in('ap_password',with:pass

javascript - typescript 2.1 with async/await 为 angularjs 生成 ES5/ES3 目标

我正在尝试在一个Angular1.5.5项目中使用async/await。鉴于此服务方式getDocumentTypes():angular.IPromise{varurl="api/document/types";this.$log.log(url);returnthis.$http.get(url).then(_=>_.data);}我正在尝试创建该方法的async/await版本。asyncgetDocTypes():angular.IPromise{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}}Intellisenseshowsanerror:TS1055

javascript - 如何使用 ng-model 显示输入元素的不同值?

在Controller中,如果有一个变量跟踪分页表的页面索引(从0开始):varpage{pageNumber:0;}问题:如何在html中显示此pageNumber变量,但始终递增+1?(因为index=0页面显然是第一页,因此应显示为Page1)此外,当模型更新时,输入中的值应该自动更改(同样:也增加+1)。 最佳答案 我认为这是$formatters和$parsers的用例。它们对模型的属性进行操作,无需在模型上创建虚拟属性。文档here.如果这不是$formatters和$parsers的用例,请纠正我。请看下面。HTML标

javascript - Angular JS : get ng-model on ng-change

我有以下HTML这是由以下带有国家列表的对象提供的$scope.countries=[{name:Afeganistão,country:AF},{name:ÁfricadoSul,country:ZA},name:Albânia,country:AL},{name:Alemanha,country:DE},{name:Andorra,country:AD}...];当我更改下拉列表值时,我希望我的模型($scope.country)在filterByCountry函数内得到更新,但事实并非如此。我在这里缺少什么? 最佳答案 ng-

javascript - ng-model 防止选中 ="checked"默认选择单选按钮

当我使用checked="checked"时,ng-model会阻止单选按钮被默认选中。有谁知道是什么原因造成的? 最佳答案 您应该使用Angular附带的ngChecked指令。文档:http://docs.angularjs.org/api/ng.directive:ngChecked 关于javascript-ng-model防止选中="checked"默认选择单选按钮,我们在StackOverflow上找到一个类似的问题: https://stacko

javascript - 解析.com : Find all objects belonging to a user with objectId

我有一个解析类,比如图片。其中每一个都属于一个用户。对此用户的引用存储在图片表/类中作为指向用户的指针。在我的云代码中,我试图使用主key获取属于某个用户的所有图片。以下是我的代码:Parse.Cloud.define("getPictures",function(request,response){Parse.Cloud.useMasterKey();varquery=newParse.Query("Pictures");query.equalTo("user",request.params.user);query.find({success:function(results){va

javascript - 模拟 :starts-with or :ends-with for searching text? 的 jQuery 选择器

如果您查看selectorslist在jQuery网站上,有用于属性开始和结束的选择器。还有一个用于搜索文本的:contains选择器:alert($("div").find("span:contains(text)").html());jQuery是否有使用开头或结尾来搜索字符串的实现?仅供引用:我需要搜索XML对象。 最佳答案 据我所知不是默认情况下,但您可以通过$.expr[":"]添加自己的伪选择器:http://jsfiddle.net/h6KYk/.$.extend($.expr[":"],{"starts-with":

javascript - 此警告消息是什么意思? 'img elements must have an alt prop, either with meaningful text, or an empty string for decorative images'

为什么我会收到此警告?warning:imgelementsmusthaveanaltprop,eitherwithmeaningfultext,oranemptystringfordecorativeimagesjsx-a11y/img-has-alt它显示第13行,但没有使用任何Prop。 最佳答案 这意味着当您在HTML中创建图像时,为了屏幕阅读器和文本浏览器的利益,您应该包含一个alt属性。 关于javascript-此警告消息是什么意思?'imgelementsmusthave

javascript - Angular 错误 : [filter:notarray] Expected array but received: {} with a filter on an ng-repeat

我正在尝试使用ng-repeat指令使用对API的Angular请求来填充html表。首先加载html页面,然后请求获取返回响应时填充表格的数据。当我向ng-repeat指令添加过滤器时,表格被填充并且过滤器起作用,但是在我的chrome浏览器控制台中,我收到以下错误:Error:[filter:notarray]Expectedarraybutreceived:{}http://errors.angularjs.org/1.4.3/filter/notarray?p0=%7B%7DatREGEX_STRING_REGEXP(angular.js:68)atangular.js:182