【发布时间】:2014-04-29 10:12:29
【问题描述】:
假设我有一个函数:
angular.forEach(myElements, function prepareElements(myEl: HTMLElement, index) {
myEl.dataset.myProperty = "whatever";
})
我遇到的问题是
error TS2094: The property 'myProperty' does not exist on value of type 'DOMStringMap'
我不太明白lib.d.ts中的interface
interface DOMStringMap {
}
declare var DOMStringMap: {
prototype: DOMStringMap;
new (): DOMStringMap;
}
以后……
interface HTMLElement {
dataset: DOMStringMap;
hidden: boolean;
msGetInputContext(): MSInputMethodContext;
}
是我自己还是有点不清楚?
我尝试投射它<DOMStringMap>myEl.dataset.myProperty = "whatever",但什么也没做...
【问题讨论】:
标签: html angularjs typescript