0

This might be me just missing something or getting the wrong end of the stick on the tutorial, so bear with me.

I have my app....

var shepApp = angular.module('shepApp', [
  'ngRoute',
  'ui-notification',
  'shepControllers',
  'shepFilters',
  'shepServices'
]);

shepApp.config(['$routeProvider',
  function($routeProvider) {
    $routeProvider.
      when('/galaxies', {
        templateUrl: "partials/galaxies.html",
        controller: 'GalaxyListCtrl'
      }).
  }]);

And my controllers go something like this....

var shepControllers = angular.module('shepControllers', []);

shepControllers.controller('GalaxyListCtrl', ['$scope', '$location', 'Notification', 'Galaxy', function($scope, $location, Notification, Galaxy) {
  $scope.galaxys = Galaxy.query();
  $scope.blah = function(){
        alert(123);
  }
}]);

shepControllers.controller('GalaxyDetailCtrl', ['$scope', '$routeParams', '$location', 'Notification', 'Galaxy', function($scope, $routeParams, $location, Notification, Galaxy) {
  $scope.galaxy = Galaxy.get({slug: $routeParams.slug});
}]);

My galaxies.html partial contains the following HTML using ng-click.

<button ng-click="blah"></button>

My thinking was that that blah function for the click event would be exposed when my route is /galaxies and the controller in use is GalaxyListCtrl - but the alert is never fired at all.

I think I am missing something in the way this all fits together.

1 Answer 1

2

Calling a function without arguments is done using the name of the function followed by parentheses:

ng-click="blah()"
Sign up to request clarification or add additional context in comments.

1 Comment

Boom. Thanks. I knew it would be something simple!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.