2
加入這個簡單的AngularJS控制器大量與Visual Studio的(DefinitelyTyped)AngularJS和打字稿問題
/// <reference path="../../../Scripts/typings/angularjs/angular.d.ts" />
"use strict";
class ProgressBarController {
static $inject: Array<string> = ["$rootScope", "$element"];
static measure = "px";
static startPageFactor = 1;
static endPageFactor = 1;
private rootScope; // todo define RootScope boilerplate
private element: JQuery;
constructor($rootScope, $element: JQuery) {
this.rootScope = $rootScope;
this.element = $element;
}
getWidth(): string {
var self = ProgressBarController,
masterBarWidth = parseFloat(this.element.css("width").split(self.measure)[0]),
totalPages = this.rootScope.app.pages.length - self.endPageFactor,
eachPageProgress = (masterBarWidth/totalPages),
currentPage = this.rootScope.app.currentIndex(),
progress = eachPageProgress * (currentPage - self.startPageFactor);
return progress + self.measure;
}
}
angular.module("myDirectives")
.controller("progressBarController", ProgressBarController);
我使用AngularJS運行後我的解決方案時,我收到了大量關於Visual Studio的打字稿編譯器錯誤的1.4.9,用於AngularJS 1.4+的DefinitelyTyped angular.d.ts和用Resharper 9.0 Update 1的Visual Studio Community 2015.我的項目的Typescript工具在1.7上,編譯器瞄準ES3以實現IE8的兼容性。
錯誤類似於400以上,95%來自jquery.d.ts。都是不同的,其中之一是「找不到名字布爾」。
我有問題,也使用NG,IAngularStatic,...的iScope所以我只是避免他們