<li role="menuitem"><a href="#" ng-click='getData1()'>Day</a></li>
<li role="menuitem"><a href="#" ng-click='getWData2()'>Week</a></li>
<li role="menuitem"><a href="#" ng-click='getMData3()'>Month</a></li>
I have these three HTML elements defined and on click I would like to call a function in Angular. The problem is I defined three functions in angular that do the same thing but use a different parameter. How can I pass a fixed parameter into this function to pass in the string therefore helping me create one reusable function called getData():
<li role="menuitem"><a href="#" ng-click='getData('Day')'>Day</a></li>
<li role="menuitem"><a href="#" ng-click='getData('Week')'>Week</a></li>
<li role="menuitem"><a href="#" ng-click='getData('Month')'>Month</a></li>
Here is the function:
$scope.getDayData = function(day){
$scope.currentInterval = "day";
$http.get("http://localhost:8080/" + day)
.then(function(response) {
});
getData()method$eventas argument and get the data usinge.target.textContent