![](/img/trans.png)
[英]Is it needed to include the hints for java lint with Typescript , VS - 2013
[英]Typescript errors in VS 2013
該文件需要引用angular.d.ts。 同樣,用於設置值的代碼也不正確。 而不是restrict: "E"
例如restrict: "E"
,它應該是public restrict = "E";
。 冒號告訴Typescript這是一個類型定義。
我很好奇,盡管為什么我需要angular.d.ts引用,以及為什么tds.d.ts無法使用,因為它反過來又會引用angular.d.ts。 通常在每個角度文件的頂部都引用d.ts文件嗎? 如果是這樣的話,這對於我的150多個angularjs文件的項目來說可能是相當多的。
這是最終的工作代碼:
///<reference path="../../../typings/angularjs/angular.d.ts" />
module eStore.PromoCode {
export class PromoCodeDirective implements ng.IDirective {
public restrict = "E";
public templateUrl = "Scripts/Checkout/PromoCode/promoCode.html";
public scope = {};
public controller = "PromoCodeController as vm";
static factory(): ng.IDirectiveFactory {
return () => new PromoCodeDirective();
}
}
angular.module("eStoreCheckout").directive("dccPromoCode", PromoCodeDirective.factory());
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.