ch05-02-log-example.html 639 Bytes
<!DOCTYPE html>
<html ng-app="notesApp">
<head>
    <title>Notes App</title>
    <script src="../../tp/angular.js"></script>
</head>
<body ng-controller="MainCtrl as mainCtrl">

    <h1> Hello Services! </h1>
    <button ng-click="mainCtrl.logStuff()">Log something</button>

    <script type="text/javascript">
        angular.module('notesApp', [])
                .controller('MainCtrl', ['$log', function ($log) {
                    var self = this;
                    self.logStuff = function () {
                        $log.log('The button was pressed');
                    };
                }]);
    </script>
</body>
</html>