var app = angular.module('myApp' , []); app.controller('myController' , ['$scope' , function($scope)) { $scope.sum = function(val) { return 3+5; }; }]);
<body> <h2>Attaching behavior to controller - AngularJS</h2> <div ng-app="myApp" ng-controller="myController"> Sum of 3 and 5 is {{sum()}} </div> </body>