![](/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.