【发布时间】:2016-02-08 10:55:51
【问题描述】:
我正在使用 AngularJS 和 Typescript。我正在使用一个外部库,我需要从该库中调用一个 AngularJS 方法,该库是我遵循 this example 的 vanilla javascript
但遗憾的是它没有用。
我得到的错误是该函数(在我的 AngularJS 类中)不是函数。
var scope = angular.element(
document.
getElementById("MainWrap")).
scope();
scope.$apply(function () {
scope.createSession(data);
});
现在这与我在打字稿中使用的vm 有关吗?
以下是打字稿代码
module MyCtrl{
interface IMyController{
createSession();
}
class MyController implements IMyController{
constructor(
){
var vm = this;
}
createSession(data){
console.log(data);
}
}
angular.module('app').controller('MyCtrl', MyController);
}
这里是 HTML
<section id="MainWrap">
</section>
有什么想法吗?
【问题讨论】:
标签: javascript angularjs typescript