Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a function defined in my controller that get's bound to an a element with ng-click, the li element in which the a element is nested also has an ng-repeat directive.
When I inspect the $scope of that controller through the angular chrome developer tools, I see that the function, in this case, $scope.goToApp is null.

I've done this a lot of other times in my other controllers, so to be sure that I didn't made any typos I've copy-pasted how I did it from another controller, but to no avail.

Controller:

(function () {
'use strict';

var controllers = angular.module('portal.controllers');

controllers.controller('applicationController',['$scope', 'ApplicationService', 'NavigationService','$rootScope', function ($scope, ApplicationService, NavigationService,$rootScope) {

    $scope.goToApp = function(appId){
        NavigationService.navigateToApp(appId, false);
    };

    $rootScope.ESS = ApplicationService.getApplications(Constants.id_ESS);
    $rootScope.SVF = ApplicationService.getApplications(Constants.id_SVF);
    $rootScope.MED = ApplicationService.getApplications(Constants.id_MED);

    $rootScope.$watch('ESS', function(newValue){
        $scope.ESS = newValue;
    });

    $rootScope.$watch('SVF', function(newValue){
       $scope.SVF = newValue;
    });

    $rootScope.$watch('MED', function(newValue){
       $scope.MED = newValue;
    });
}]);
}());

HTML:

<li data-ng-repeat="tool in ESS | filter: {tool:true} | orderBy:'description'" class="col-lg-12">
    <a class="toolLink" href="#" data-ng-click="goToApp({{tool.code}})">{{ tool.description }}</a>
</li>

Debugger:

goToApp: null
share|improve this question
 
Remove curly braces from within: data-ng-click="goToApp(tool.code)" –  CodeHater Nov 29 at 9:47
 
thanks a lot, add it as an answer and I'll gladly accept it man :) –  J.Pip Nov 29 at 9:49
add comment

1 Answer

up vote 2 down vote accepted

ngClick accepts an expression as a parameter. No need of using interpolation:

data-ng-click="goToApp(tool.code)"
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.