草庐IT

sonata_type_collection

全部标签

javascript - Angular 2 : Type 'Subscription' is not assignable to type

我创建了一个非常小的应用程序来从json文件中获取国家并将其绑定(bind)到下拉列表。countries.jsonexportclassCountry{id:number;name:string;}factory.service.tsimport{Injectable}from'@angular/core';import{Http,Response}from'@angular/http';import{Observable}from'rxjs/Observable';import{Country}from'./shared/country';@Injectable()exportcl

javascript - "Resource interpreted as script but transferred with MIME type text/html."

很抱歉,如果这实际上是重复的,但我还没有设法找到我的问题的答案。我使用jQuery的$.getScript加载脚本。但它会导致以下错误:ResourceinterpretedasscriptbuttransferredwithMIMEtypetext/html.该问题仅在MacOS下的Safari中出现如果查看从服务器收到的header,它们包含Content-Type:application/x-javascript,所以我真的不明白问题出在哪里。 最佳答案 Resourceinterpretedasscriptbuttransf

javascript - Backbone.Collection 通过 id 获取模型

我有一个从服务器获取模型的集合。这行得通,现在我想通过MyCollection.at(0)的id获取一个模型,我得到:child_changes:Array[0]_changing:false_currentAttributes:Object_events:Object_hasComputed:true_pending:false_previousAttributes:Objectattributes:Object_id:"50ef7a63b2a53d17fe000001"author_name:"authorname"bookmark:""info:"bookmarkdescript

javascript - Backbone : fetch collection from server

我正在尝试从我的服务器获取一个集合。我使用的是0.3.3版(不是来自github的master)但是我在这个异常中运行:UncaughtTypeError:Cannotuse'in'operatortosearchfor'id'in{id=MyId,active=true}jQuery.jQuery.extend._Deferred.deferred.resolveWith(jquery.js:869)done(jquery.js:6591)jQuery.ajaxTransport.send.callback这是我创建错误的方式:varMyModel=Backbone.Model.ex

javascript - typescript TS7015 : Element implicitly has an 'any' type because index expression is not of type 'number'

我在Angular2应用程序中遇到此编译错误:TS7015:Elementimplicitlyhasan'any'typebecauseindexexpressionisnotoftype'number'.导致它的代码是:getApplicationCount(state:string){returnthis.applicationsByState[state]?this.applicationsByState[state].length:0;}但这不会导致此错误:getApplicationCount(state:string){returnthis.applicationsBySt

javascript - 尝试使用 gh-pages 部署我的 React 应用程序但收到此错误消息 : The "file" argument must be of type string. Received type undefined

我试图用gh-pages部署我的React应用程序,但我遇到了这个错误:"file"参数必须是字符串类型。接收类型未定义。起初,我以为这是我的代码,所以我制作了另一个没有修改的create-react-app,尝试使用npmrundeploy命令进行部署,但再次收到此错误消息。我的package.json(我添加了我的homepage链接、predeploy和deploy脚本,以及gh-页面依赖):"name":"test-deploy","version":"0.1.0","private":true,"homepage":"https://vnsteven.github.io/te

javascript - 错误 TS7017 : Index signature of object type implicitly has an 'any' type in form validation angular 2

我在给出的Angular2中进行响应式(Reactive)验证时遇到编译错误errorTS7017:Indexsignatureofobjecttypeimplicitlyhasan'any'type为了this.comErrors[field]='';constmessages=this.validationMessages[field];this.comErrors[field]+=messages[key]+'';它正在按应有的方式运行,但是当我尝试运行npmrunbuild.prod时,出现错误并且无法构建我的项目这是我的代码:onValueChanged(data?:any)

javascript - Backbone : Adding a model to a collection from a collection view?

我有一些代码,我希望NoteCollectionView向NoteCollection添加新的Note。这是由NoteCollectionView中的函数newNote触发的:newNote:function(data){varnote=newNote(data);this.collection.add(note);},我对主干还是很陌生,我想确保它与服务器同步。我担心的是:1)将此注释简单地添加到集合中是否会从服务器触发save(),并使用服务器提供的ID更新模型?或者,2)如果服务器没有更新我的模型并给我一个实际的ID,我该如何使用note.save()保存模型并从服务器取回一个I

javascript - 错误 TS2315 : Type 'ElementRef' is not generic material angular

在项目中添加AngularMaterial时出错ERRORinnode_modules/@angular/material/button-toggle/typings/button-toggle.d.ts(136,20):errorTS2315:Type'ElementRef'isnotgeneric.node_modules/@angular/material/button-toggle/typings/button-toggle.d.ts(154,104):errorTS2315:Type'ElementRef'isnotgeneric我正在尝试安装MaterialDesign,但

javascript - Swagger 'GET' 请求总是以 text/html 形式返回 Accept type on response 而不是 application/json

我有一个使用SwaggerUI的swagger标签文档,它总是返回text/html但它应该返回application/json。POST请求和所有其他类型都返回application/json但这个特定的GET请求不会。服务端点代码正确。如果我将请求更改为POST,它会作为application/json返回。所以它只是在swagger中键入GET,它不会返回正确的类型。有没有想过如何更正UI中的调用以使用application/json?这是最近从swagger站点下载的swagger版本2.1.4。"/bankName":{"get":{"summary":"BankNameSe