【发布时间】:2015-03-31 01:18:54
【问题描述】:
我正在尝试通过 ng-click 的超链接调用 JavaScript 原型函数,如下所示。但我无法在点击链接时触发getInfo() 功能。我是否缺少任何基础知识或做错了什么?
这是我的 JS:
$(document).ready(function () {
function Apple() {
this.type = "fff";
this.color = "red";
}
Apple.prototype.getInfo = function () {
alert( this.color + ' ' + this.type + ' apple');
};
var appl = new Apple();
});
这是我的html:
<a href="" ng-click="appl.getInfo()">click</a>
【问题讨论】:
-
你的控制器在哪里
-
您应该在控制器中创建对象并将应用程序分配给范围
标签: javascript jquery angularjs jquery-events