我怎样才能设置延迟retryWhen?
import 'rxjs/add/operator/retry';
import 'rxjs/add/operator/retrywhen';
Run Code Online (Sandbox Code Playgroud)
...
constructor(http: Http) {
var headers = new Headers();
headers.append('Content-Type', 'text/plain');
http.post('https://mywebsite.azurewebsites.net/account/getip', "", { headers: headers })
.retryWhen(errors => {
return errors.delay(1000); // errors is not a function
})
(event) => {
// handle events
this.ip = event.json();
},
(error) => {
console.error(error);
toastr.error('No connection to server. Please reload the page!')
}
);
}
Run Code Online (Sandbox Code Playgroud)
我收到错误:errors is not a function.
我得到了对象
IEnumerable<ObjectStateEntry> om = context.ObjectStateManager.GetObjectStateEntries(System.Data.EntityState.Modified);
Run Code Online (Sandbox Code Playgroud)
如何获取List字符串给出的类型的对象?
Type typ = Type.GetType("mytype");
var om2 = om.Select(s => s.Entity).OfType<typ>(); // does not work
Run Code Online (Sandbox Code Playgroud) 我通过AJAX和Web Api将JSON对象发送到我的服务器:
var data = [
["fdsfsd", "Kifdsfa", "fsdfsa", "fadsf", "fasdfsd", "fadsf", "fasdfsd"],
["2008", "-5", "11", "12", "13"],
["2009", "20", "-11", "14", "13"],
["2010", "30", "15", "-12", "readOnly"]
];
$.ajax({
url: '../webapi/Products',
type: 'POST',
dataType: "text",
data: "="+JSON.stringify( data ),
success: function (test) {
alert(test);
},
error: function (test) {
alert("Error");
}
Run Code Online (Sandbox Code Playgroud)
所以我在服务器上获得了我想用JSON.NET解析的值:
public void Post([FromBody]string value )
{
JObject o = JObject.Parse(@value);
}
Run Code Online (Sandbox Code Playgroud)
这引发了异常:
Error reading JObject from JsonReader. Current JsonReader item is not an object:
StartArray. Path '', …Run Code Online (Sandbox Code Playgroud) 我想使用Signalr将对象从Javascript发送到服务器,但不调用服务器端方法.
// Model-Class generated by EF5.0
public partial class ttFragen
{
...
public long ID { get; set; }
public Nullable<long> UserID { get; set; }
public string Titel { get; set; }
public string Text { get; set; }
public Nullable<int> ProductID { get; set; }
public Nullable<int> Score { get; set; }
public Nullable<System.DateTime> Date { get; set; }
}
public class Chat : Hub
{
public void Send2(ttFragen frage)
{
...
}
}
Run Code Online (Sandbox Code Playgroud)
客户代码:
$.connection.hub.start().done(function() {
$("#broadcast").click(function …Run Code Online (Sandbox Code Playgroud) 在VS2012中,可以通过上下文菜单-> paste special将JSON作为c#类粘贴。
是否有解决方案可以做到这一点?将ac#类粘贴为JSON吗?
我认为许多开发人员首先例如使用EF DBContext编写服务器代码,然后再使用客户端javascript代码。总是用手编写json很复杂。
一个例子:
// a model class
public class SampleTodoItem
{
public int Id { get; set; }
public string Description { get; set; }
public bool IsDone { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
那么我想在我的JavaScript客户端代码中使用与json相同的模型。当然,在生成的JSON中必须有伪数据。
var model = {
id: 0,
description: 'dummy',
isDone: false
};
Run Code Online (Sandbox Code Playgroud)
我总是必须手动完成,这很糟糕。
据我了解,我需要这些“ JSON模型”以使用剔除或angularjs将javascript数据绑定到html视图。也有可能我不了解整个事情。
我想针对ES5,所以我在我的Visual Studio项目文件中设置:
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<TypeScriptTarget>ES5</TypeScriptTarget>
<TypeScriptIncludeComments>false</TypeScriptIncludeComments>
<TypeScriptSourceMap>false</TypeScriptSourceMap>
<TypeScriptModuleKind>AMD</TypeScriptModuleKind>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
但现在我得到error MSB6006: "tsc.exe" exited with code 1.ES3我没有得到错误.
我使用bootstrap并创建包含jQuery弹出窗口的html节点.弹出窗口包含html,所以我有引号和转义问题:
var content = '<input type="text" ng-model="test1" />';
var txt = '<button type="button" data-container="body" ' +
'data-toggle="popover" title="myTitle" data-html="true" '+
'data-content="'+content+'">Click</button>';
Run Code Online (Sandbox Code Playgroud)
如何在attributes => html-attributes中转义双引号?在数据内容属性中正确吗?
编辑:我使用angular编译代码,以便它也可以使用它.
当我不时通过 python 将数据发布到 firebase 时,我收到错误:
HTTPError: 502 Server Error: Bad Gateway
Run Code Online (Sandbox Code Playgroud)
这似乎是随机的。我无法确定原因。有时我也遇到通过 C# 从 firebase 获取数据的问题。重试几次后就可以了。
<div *ngFor="let f of layout?.photoframes; let i = index" [attr.data-index]="i">
<input type="number" [(ngModel)]="f.x" [style.border-color]="(selectedObject===f) ? 'red'" />
</div>
Run Code Online (Sandbox Code Playgroud)
条件样式抛出错误
Conditional expression (selectedObject===f) ? 'red' requires all 3 expressions at the end
of the expression [(selectedObject===f) ? 'red'] what can I do?
Run Code Online (Sandbox Code Playgroud)
我能做什么?
默认情况下,ASP.NET Identity用户数据存储在mdf文件中.
我想将数据存储在Sql数据库中,以便将my中的defaultconnection字符串更改为web.config基于EF的连接:
<add name="DefaultConnection" connectionString="metadata=res://*/Models.StartifyModel.csdl|res://*/Models.StartifyModel.ssdl|res://*/Models.StartifyModel.msl;provider=System.Data.SqlClient;provider connection string="data source=MYPC\SQLEXPRESS;initial catalog=mydb;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
Run Code Online (Sandbox Code Playgroud)
现在The entity type ApplicationUser is not part of the model for the current context.,只要我想注册用户,我就会收到错误.
我使用VS2013的默认MVC5项目模板.
javascript ×4
asp.net ×3
c# ×3
json ×3
angular ×2
typescript ×2
ajax ×1
angularjs ×1
asp.net-mvc ×1
escaping ×1
firebase ×1
generics ×1
json.net ×1
observable ×1
plugins ×1
python ×1
signalr ×1
sql ×1
types ×1