1
我想從angularjs2發佈數據到asp.net mvc控制器。Angular 2將數據發佈到asp.net mvc控制器
實際的問題是,當我與它試圖然後
見我怎麼想?
這是打字稿---
save(company: Company): Observable<boolean> {
let headers = new Headers({ 'Content-Type': 'application/json' });
this._http.post(this._postUrl, /*JSON.stringify(*/company/*)*/, { headers: headers })
.subscribe(
(data) => {
console.log('Response');
new Observable<true>()
},
(err) => { console.log(err); new Observable<false>(); },
() => console.log('Complete')
);
return new Observable<false>();
}
onSignUpClicked(message: string): void {
this._service.save(this.company).subscribe(
res => console.log(res),
error => this.errorMessage = <any>error
);
這是打字稿類:
import { Address } from '../shared/Address';
import { Contact } from '../shared/Contact';
export class Entity {
Id: string;
InsertionTime: Date;
InsertUserId: number;
IsDeleted: boolean;
IsLocked: boolean;
UpdateTime: Date;
UpdateUserId: number;
}
export class Company extends Entity {
Name: string;
Address: Address;
Contact: Contact;
Password: string;
ConfirmPassword: string;
UserName: string;
RegistrationDate: Date;
IsActive: boolean;
NextBillingDate: string;
TransactionLimit: number
}
和C#類
public class Company : Entity
{
public string Name { get; set; }
public Address Address { get; set; }
public Contact Contact { get; set; }
public string Password { get; set; }
public string UserName { get; set; }
public Image LogoImage { get; set; }
public DateTime RegistrationDate { get; set; }
public DateTime LastUpdated { get; set; }
public bool IsActive { get; set; }
public DateTime NextBillingDate { get; set; }
public Int64 TransactionLimit { get; set; }
}
public class Entity : IEntity
{
public Entity()
{
Id = Guid.NewGuid();
InsertionTime = DateTime.Now;
IsDeleted = false;
IsLocked = false;
}
public Guid Id
{
get;set;
}
public DateTime InsertionTime
{
get;set;
}
public int InsertUserId
{
get; set;
}
public bool IsDeleted
{
get; set;
}
public bool IsLocked
{
get; set;
}
public DateTime? UpdateTime
{
get;set;
}
public int? UpdateUserId
{
get; set;
}
}
任何幫助讚賞
你得到了什麼錯誤? – brando