如何在工厂服务中定义的 ng-click 中调用该函数,
app.factory('MyFactory', [function () {
return {
setTest: function(test) {
alert(test);
}
};
}]);
app.controller('TestCtrl', ['$scope','MyFactory', function ($scope, MyFactory) {
}]);
<li><a href="#" ng-click="setTest('PHP')">PHP</a></li>
<li><a href="#" ng-click="setTest('Javascript')">Javascript</a></li>