angular get image data and again append it to FormData

In angular 5 I am getting the images for hotelgallery from mongodb through my service. So basically the data what I am getting is like this { fieldname: "hotelgallery", originalname: "e.jpg", encoding: "7bit", mimetype: "image/jpeg", destination: "./public/", encoding : "7bit", filename : "1521139307413.jpg" mimetype : "image/jpeg" path : "public/1521139307413.jpg" size

角度获取图像数据,并再次将其附加到FormData

在angular 5中,我通过我的服务从mongodb获取hotelgallery的图像。 所以基本上我得到的数据就是这样 { fieldname: "hotelgallery", originalname: "e.jpg", encoding: "7bit", mimetype: "image/jpeg", destination: "./public/", encoding : "7bit", filename : "1521139307413.jpg" mimetype : "image/jpeg" path : "public/1521139307413.jpg" size : 66474 } { fieldname: "hotelgallery", or

Mixins as utility library in Polymer 2.0

I am working in web application project which is made in Polymer 2.0, All Custom elements extends some Mixins. Some of those Mixins just provide utility functions to custom elements just like Date Time Utility functions or any Math related functions. My question is whether to use mixins & extends them to custom elements or just wrap them in plain java-script file and load that java-script f

Mixins作为Polymer 2.0中的实用程序库

我正在使用Polymer 2.0制作的Web应用程序项目中,所有自定义元素都扩展了一些Mixins。 这些Mixin中的一些仅为自定义元素提供实用功能,就像Date Time Utility函数或任何数学相关函数一样。 我的问题是,是否使用mixins并将它们扩展到自定义元素,或者只是将它们包装在普通的java脚本文件中,并将该java脚本文件加载到index.html或应用程序的入口点,并将其用作全局范围,就像我们使用lodashjs或underscore.js。 我发现Mixin

DevExtreme dxGrid lookup column form display id instead of DisplayExpr

I am using DevExtreme dxGrid to display and edit data for users, and I have a lookup column to chose the user department. The data display in grid correctly but after I press the edit button and the popup form show up the lookup field display the id value of the department, not the value specified in DisplayExpr , but when I click the dropdown the values displayed correctly. I have searched a

DevExtreme dxGrid查找列窗体显示ID而不是DisplayExpr

我使用DevExtreme dxGrid为用户显示和编辑数据,并且我有一个查找列来选择用户部门。 数据正确显示在网格中,但在按下编辑按钮后,弹出窗体显示查找字段显示部门的id值,而不是DisplayExpr指定的值,但是当我单击下拉列表时,显示的值正确。 我在DevExpress网站上搜索了很多,并尝试了他们所说的关于数据源和JS之间类型不匹配的所有内容,并且没有任何效果。 cshtml代码: @(Html.DevExtreme().DataGrid().ID("gridContain

Creating multiline strings in JavaScript

I have the following code in Ruby. I want to convert this code into JavaScript. what's the equivalent code in JS? text = <<"HERE" This Is A Multiline String HERE Update: ECMAScript 6 (ES6) introduces a new type of literal, namely template literals . They have many features, variable interpolation among others, but most importantly for this question, they can be multiline. A tem

在JavaScript中创建多行字符串

我在Ruby中有以下代码。 我想将此代码转换为JavaScript。 JS中的等效代码是什么? text = <<"HERE" This Is A Multiline String HERE 更新: ECMAScript 6(ES6)引入了一种新的文字,即模板文字 。 它们有许多特征,其中包括可变插值,但对于这个问题最重要的是,它们可以是多行的。 模板文字由反引号分隔: var html = ` <div> <span>Some HTML here</span> </div> `; (注

How does JavaScript .prototype work?

I'm not that into dynamic programming languages, but I've written my fair share of JavaScript code. I never really got my head around this prototype-based programming, does any one know how this works? var obj = new Object(); // not a functional object obj.prototype.test = function() { alert('Hello?'); }; // this is wrong! function MyObject() {} // a first class functional object MyObj

JavaScript .prototype如何工作?

我不是那么喜欢动态编程语言,但是我已经写了我的JavaScript代码。 我从来没有真正理解这个基于原型的编程,有没有人知道这是如何工作的? var obj = new Object(); // not a functional object obj.prototype.test = function() { alert('Hello?'); }; // this is wrong! function MyObject() {} // a first class functional object MyObject.prototype.test = function() { alert('OK'); } // OK 我记得很久以前我和人们

How to insert an item into an array at a specific index?

I am looking for a Javascript array insert method, in the style of: arr.insert(index, item) Preferably in jQuery, but any Javascript implementation will do at this point. What you want is the splice function on the native array object. arr.splice(index, 0, item); will insert item into arr at the specified index (deleting 0 items first, that is, it's just an insert). In this example we

如何将项目插入到特定索引处的数组中?

我正在寻找一种Javascript数组插入方法,风格如下: arr.insert(index, item) 最好在jQuery中,但任何Javascript实现都会在这一点上做。 你想要的是本地数组对象上的splice函数。 arr.splice(index, 0, item); 将item插入到指定索引的arr中(首先删除0项目,即它只是一个插入)。 在这个例子中,我们将创建一个数组并添加一个元素到索引2中: var arr = []; arr[0] = "Jani"; arr[1] = "Hege"; arr[2] = "Stale"; ar

down list (select box) using jQuery

我如何从jQuery的下拉列表中获取选定的文本(不是选定的值)? $("#yourdropdownid option:selected").text(); Try this: $("#myselect :selected").text(); For an ASP.NET dropdown you can use the following selector: $("[id*='MyDropDownId'] :selected") The answers posted here, for example, $('#yourdropdownid option:selected').text(); didn't work for me, but this did: $('#yourdropdownid').find('o

下拉列表(选择框)使用jQuery

我如何从jQuery的下拉列表中获取选定的文本(不是选定的值)? $("#yourdropdownid option:selected").text(); 尝试这个: $("#myselect :selected").text(); 对于ASP.NET下拉菜单,您可以使用以下选择器: $("[id*='MyDropDownId'] :selected") 例如,在这里发布的答案, $('#yourdropdownid option:selected').text(); 不适合我,但是这样做: $('#yourdropdownid').find('option:selected').text(); 它可能是jQuery的

How do I loop through or enumerate a JavaScript object?

I have a JavaScript object like the following: var p = { "p1": "value1", "p2": "value2", "p3": "value3" }; Now I want to loop through all p elements ( p1 , p2 , p3 ...) and get their keys and values. How can I do that? I can modify the JavaScript object if necessary. My ultimate goal is to loop through some key value pairs and if possible I want to avoid using eval . You can u

如何遍历或枚举JavaScript对象?

我有一个JavaScript对象,如下所示: var p = { "p1": "value1", "p2": "value2", "p3": "value3" }; 现在我想遍历所有p元素( p1 , p2 , p3 ...)并获取它们的键和值。 我怎样才能做到这一点? 如有必要,我可以修改JavaScript对象。 我的最终目标是循环访问一些关键值对,如果可能,我想避免使用eval 。 您可以使用其他人显示的for-in循环。 但是,您还必须确保所获得的密钥是对象的实际属性,而不是来

How can I refresh a page with jQuery?

我如何使用jQuery刷新页面? Use location.reload() : $('#something').click(function() { location.reload(); }); The reload() function takes an optional parameter that can be set to true to force a reload from the server rather than the cache. The parameter defaults to false , so by default the page may reload from the browser's cache. 这应该适用于所有浏览器,即使没有jQuery: location.rel

我如何使用jQuery刷新页面?

我如何使用jQuery刷新页面? 使用location.reload() : $('#something').click(function() { location.reload(); }); reload()函数采用一个可选参数,该参数可以设置为true以强制从服务器而不是缓存重新加载。 该参数默认为false ,因此默认情况下该页面可能会从浏览器的缓存中重新加载。 这应该适用于所有浏览器,即使没有jQuery: location.reload(); 有多种无限制的方式可以用JavaScript刷新页面: location.reload

Storing Objects in HTML5 localStorage

I'd like to store a JavaScript object in HTML5 localStorage , but my object is apparently being converted to a string. I can store and retrieve primitive JavaScript types and arrays using localStorage , but objects don't seem to work. Should they? Here's my code: var testObject = { 'one': 1, 'two': 2, 'three': 3 }; console.log('typeof testObject: ' + typeof testObject); console.

将对象存储在HTML5 localStorage中

我想在HTML5 localStorage存储JavaScript对象,但我的对象显然正在转换为字符串。 我可以使用localStorage存储和检索原始JavaScript类型和数组,但对象似乎不起作用。 他们应该吗? 这是我的代码: var testObject = { 'one': 1, 'two': 2, 'three': 3 }; console.log('typeof testObject: ' + typeof testObject); console.log('testObject properties:'); for (var prop in testObject) { console.log(' ' + prop +