我有以下 2 个函数/类
function Availability(){
this.Click = function (){
alert("Availability");
}
}
function Help(){
this.Click = function (){
alert("Help");
}
}
我创建了以下模块:
var Gadgetory = angular.module("Gadgetory", []);
和以下控制器:
var ToolbarController = Gadgetory.controller('ToolbarController', ['$scope',
function ($scope)
{
$scope.greeting = 'Gadgetory!';
$scope.Gadgets = [
{ name: "Availability", icon: "available.png", object: new Availability() },
{ name: "Help", icon: "help.png", object: new Help() }
];
}
]);
现在在我的 html 中,我想调用字典中每个小工具的 click 方法,如下所示:
<div ng-repeat="gadget in Gadgets">
<img ng-src="/Gadgets/{{gadget.icon}}" ng-click="{{gadget.object}}.Click()"/>
</div>
但这不起作用,你能帮帮我吗?