草庐IT

bit_data_models

全部标签

javascript - 为什么我的 ng-model 变量在 Controller 中未定义?

我在angularjs项目中遇到$scope问题。例如,当我在输入字段上使用ng-model="modelExample"时,我无法使用$scope.modelExample在我的js中访问它。有没有其他人遇到过类似的问题?这很奇怪,调用了一个函数但ng-model没有绑定(bind)。请参阅下面的代码,当我提交表单时调用函数refreshResults()但$scope.search返回未定义。angular.module('starter',['ionic','starter.controllers','starter.filters','akoenig.deckgrid',"an

javascript - 在 AngularJS 中设置动态 ng-model 名称

还有类似的问题here和here,虽然我的用例有点不同。我有一个名为uniqueLists的对象,它看起来像这样:$scope.uniqueLists-{name:['string1','string2','string3'//Lotsofstrings],Category:['string1','string2','string3'//Lotsofstrings],designer:['string1','string2','string3'//Lotsofstrings]}我正在尝试从这个列表中构建一个搜索功能。目前,我可以像这样在页面上的复选框中显示所有列表项(以下代码使用Jad

Javascript/jQuery : Reordering divs according to data-attribute values

这个问题在这里已经有了答案:关闭9年前。PossibleDuplicate:Sortelementbynumericalvalueofdataattribute我想根据设置在它们上的数据属性重新组织div,范围从最高整数到最低整数。现在,我将所有数据插入一个数组并对其进行排序,但我不确定如何进行。我如何使用它来重组其父div内的div?varprices=newArray();$(this).children('.listing-item').each(function(){varprice=parseInt($(this).attr('data-listing-price'));pr

javascript - Angular 力矩 : Moment Timezone has no data for America/New_York

从服务器收到的日期是UTC时区,我需要将其转换为特定时区,例如:America/New_York。以下是相同的代码但是在这样做时我得到了以下错误:MomentTimezonehasnodataforAmerica/New_York.Seehttp://momentjs.com/timezone/docs/#/data-loading/.但是America/New_York是moment的已知时区,但它仍然要求我添加时区。 最佳答案 您需要加载以下所有内容:时刻时刻时区moment-timezone的时区数据Angular矩关于mom

javascript - input[radio] 与 ng-model 和 ng-value 的对象相等性比较

首先让我说这个问题与中的选择问题非常相似使用ng-options标记。例如,WorkingwithselectusingAngularJS'sng-options.具体问题是比较一个对象的两个不同实例,这两个实例的引用不相等,但逻辑上表示相同的数据。为了演示,假设我们在模型中有以下选项数组和选定的选项变量:$scope.items=[{ID:1,Label:'Foo',Extra:17},{ID:2,Label:'Bar',Extra:18},{ID:3,Label:'Baz',Extra:19}];$scope.selectedItem={ID:1,Label:'Foo'};请注意,

javascript - 获取 : post json data, application/json 更改为 text/plain

我使用的是chrome53.0.2785.116m(64位)。我在devtools上得到了以下标题。该问题标有“//”注释。内容类型真的不允许我们将其设置为application/json,我已经尝试了100种不同的方法。importfetchfrom'isomorphic-fetch';constoption={method:'POST',mode:'no-cors',headers:{'Accept':'application/json','Content-Type':'application/json'},body:JSON.stringify({'aa':'bb'})}fetc

javascript - AngularJS 用户界面路由器 : how to resolve typical data globally for all routes?

我有一个与服务器通信并返回的AngularJS服务应用程序不同部分的翻译:angular.module('utils').service('Translations',['$q','$http',function($q,$http){translationsService={get:function(section){if(!promise){varq=$q.defer();promise=$http.get('/api/translations',{section:section}).success(function(data,status,headers,config){q.res

javascript - Uncaught TypeError : this. state.data.map 不是函数

我是React的新手,见过一些类似的问题,但没有找到为什么会这样。我收到“未捕获的类型错误:this.state.data.map不是函数”。这是代码。请帮助找出问题所在。classAudiensesextendsReact.Component{constructor(props){super(props);this.state={data:''};this.loadFromServer=this.loadFromServer.bind(this);this.childeDelete=this.childeDelete.bind(this);this.childeEdit=this.c

javascript - AngularJS - 将 ng-model 绑定(bind)到一个名称存储在另一个变量中的变量

我正在尝试将输入字段的值绑定(bind)到一个变量。我不知道这个变量的名称​​apriori;它存储在另一个变量中。这是html:这是Controller:functionstageController($scope){$scope.model='realModel';//containsthenameofthevariablethatiwouldbindtothefield$scope.realModel='initialvalueofthefield';}我也做了一个fiddle.这不起作用,因为当前绑定(bind)在输入字段和model变量之间。相反,我会将输入字段绑定(bind

vue触屏项目 使用 虚拟键盘组件,通过js给el-input value赋值,v-model绑定值不同步问题(已修改)

1.管理后台项目每个页面都有模糊搜索,之前是使用外接键盘或者扫码枪进行输入,完全没有问题,但是最近客户使用的是触屏手动输入,就发现了问题,输入框上的值并不会被监听到,也不会触发el-input框自带的enter,以及change事件,这时候就想着接入一个虚拟键盘,在触屏项目中使用,接入完成后本以为可以成功,但是发现,通过js给el-inputvalue赋值,v-model绑定值不会同步问题:.赋值后,界面显示字段已更改,获取v-model的参数,发现不会同步更改解决办法:v-model只是一种语法糖,底层的方法还是去监听input事件。所以可以使用dispatchEvent事件给元素分配一个i