Мне нужно создать объект. class & их свойства и создание объектов происходят в разных файлах.Класс не определен на typeScript
это файл, который включает класс
module Model {
export class DonationServiceResponse {
ErrorMessage: string;
ErrorCode: number;
Comapny: string;
StreateName: string;
IsAnonymous: boolean;
IsOneOffDonation: boolean;
DonationIntentType: number;
EmployeeId: number;
Amount: number;
LogoImage: string;
Id: number;
}}
в создании объекта ниже файлового произошло
/// <reference path="DonationServiceResponse.ts" />
/// <reference path="../../typings/angularjs/angular.d.ts" />
angular.module('myApp', []);
interface IDonationServiceController {
Tiles: Array;
TileContainerEntities: Array;
TotalAmount: number;
}
class TileContainerEntity {
DonationContainer: test.DonationServiceResponse;
httpService: any;
scope: any;
res: boolean;
AnonymousText: string;
OneTimeText: string;
constructor(donationAmount: number, charityLogo: string, anonymous: bool, oneTime: bool, id: number, employeeId: number, http: ng.IHttpService, scope: ng.IHttpService) {
this.DonationContainer = new test.DonationServiceResponse();
this.DonationContainer.Amount = donationAmount;
this.DonationContainer.LogoImage = charityLogo;
this.DonationContainer.Id = id;
this.DonationContainer.EmployeeId = employeeId;
this.httpService = http;
this.scope = scope;
}
}
class DonationServiceController implements IDonationServiceController {
private httpService: any;
TotalAmount: number = 0;
Tiles: TileContainerEntity[];
TileContainerEntities: TileContainerEntity[];
constructor($scope, $http: ng.IHttpService) {
this.httpService = $http;
$scope.VM = this;
this.getAllTiles($scope.VM, $http);
}
getAllTiles(scope, http): void {
this.httpService.get("/API/PrivateAPI/test").success(function (data, status) {
this.TileContainerEntities = [];
var num = 0;
for (var index = 0; index < data.length; index++) {
var amount = data[index].Amount;
var chairtyLogo = data[index].LogoImage;
var isAnonymousOff = data[index].IsAnonymous;
var isOneOff = data[index].IsOneOffDonation;
var id = data[index].Id;
var empId = data[index].EmployeeId;
var tileEntity = new TileContainerEntity(amount, chairtyLogo, isAnonymousOff, isOneOff, id, empId, http, scope);
this.TileContainerEntities.push(tileEntity);
num = num + data[index].Amount;
}
scope.Tiles = this.TileContainerEntities;
scope.TotalAmount = num;
});
}
}
моя проблема в стороне конструктор DonationContainer показывает, как неопределенный объект. он не инициализируется. если я использую один файл для этой вещи (нет двух файлов), его работы хорошо. Кто-нибудь знает, как это сделать, и причина для этого?
Отъезд http://youtube.com/watch?v=KDrWLMUY0R0, чтобы просмотреть различные параметры управления файлами из машинописного текста – basarat
Также у меня есть специальный рабочий процесс для углового + машинописного текста. Я хотел бы рекомендовать http://youtube.com/ #/смотреть? v = 0-6vT7xgE4Y & HD = 1 – basarat