在我的 angular2 项目中,我使用 grunt 来自动编译我的打字稿文件。
一切都很好我的文件正在编译但总是出错
app/webapp/ng2/audit_logs/auditLogs.ts(2,3): error TS2304: Cannot find name 'app'.
app/webapp/ng2/audit_logs/auditLogs.ts(3,3): error TS2304: Cannot find name 'http'.
app/webapp/ng2/audit_logs/auditLogs.ts(3,10): error TS2304: Cannot find name 'ng'.
app/webapp/ng2/audit_logs/auditLogs.ts(6,3): error TS2304: Cannot find name 'app'.
app/webapp/ng2/audit_logs/auditLogs.ts(7,5): error TS2304: Cannot find name 'ng'.
app/webapp/ng2/main.ts(16,24): error TS2304: Cannot find name 'upgradeAdapter'.
我尝试过Definetlytyped,但没有成功。
我不知道为什么?
请帮我解决这个问题,main.ts and auditLogs.ts
看看我的文件,让我知道哪里做错了
Main.ts 文件
/// <reference path="../../../node_modules/angular2/typings/browser.d.ts" />
var window: any = {
giddh: undefined
};
import {UpgradeAdapter} from 'angular2/upgrade';
var adapter = new UpgradeAdapter();
var app = window.giddh.webApp;
adapter.bootstrap(document.body, ['giddhWebApp']);
// downgrade ng2 components to ng1 directives
app.directive('myApp', upgradeAdapter.downgradeNg2Component(app.AppComponent));
auditLogs.ts 文件
(function(giddh: any) {
app = giddh.webApp
http = ng.http
app.AppComponent =
ng.core.Component({
selector: 'my-app',
templateUrl: ''
}).Class({
constructor: function(http: any) {
this.test = new test(1020);
}
});
class test {
val: string;
constructor(data: any){
this.val = data;
}
}
})(window.giddh || (window.giddh = {}));
var window: any = {
giddh: undefined
}
declare var require: any;
import {Component} from 'angular2/core';
@Component({
selector: 'my-app',
template: '/public/webapp/ng2/audit_logs/audit-logs.html'
})
export class AppComponent {
}