Search code examples
javascriptjqueryangularjsangularjs-directiveangular-kendo

How to call an angular $scope function using href in angular-kendojs


I am new to angular-kendo.js. I want to call a function emailClick() from href ie.

<a href="javascript:void(0);" k-on-click = "emailClick()">Email</a>

and my controller and route is as follows :

app.controller('ContactCtrl', ['$rootScope', '$scope', 'appSvc',
 function($scope, $rootScope, appSvc) {
    $scope.emailClick = function() {
        appSvc.selectItem = 'email';
        appSvc.back = true;
        $rootScope.go('email', 'slideLeft');
    };
 }]);

app.config(['$routeProvider',
        function($routeProvider) {
            $routeProvider.when('/', {
                templateUrl : 'partials/home.html',
                controller : 'HomeCtrl'
            }).when('/email', {
                templateUrl : 'partials/email.html',
                controller : 'ContactCtrl'
            }).otherwise({
                templateUrl : 'partials/home.html',
                controller : 'HomeCtrl'
            });
        }]);
    }());

Now on clicking Email I should go to the function emailClick() but it is not happpening. there is no error and no response. Please help.

Thanks in advance.


Solution

  • you need to use ng-click directive,

     <a href="javascript:void(0);" ng-click = "emailClick()">Email</a>