Call service method from ngClick directly without calling the controller function

53 views Asked by At

I have an AngularJS service as shown below:

.service('CommonProp', function ($location) {
    return {
        log: function () {
            // Do stuff
        }
    };
});

I'm calling the above method log from a controller function which is invoked from a ngClick on an anchor tag.

$scope.calllog = function(){
    CommonProp.log();
}

HTML code:

<a ng-click="callog()" />

In the above code, the controller function is doing nothing much except calling the service method. Is there a way to call service method from the ng click directive without calling the controller function.

0

There are 0 answers