Our site uses cookies. Learn more about their purpose and change of settings in a browser If you are using the site, you give you consent to use cookies, according to current browser settings. Got it

Angular egghead 17 - An alternative approach to controllers

  • Language JavaScript
Angular egghead is set of tests which depends on Egghead lessons. This exercise tests your knowledge about controller as syntax.

Exercise 17: An alternative approach to controllers


An alternative approach to controllers assumes that the function should be assigned to the controller, not to the $scope. Create SumCtrl and SubCtrl providing the basic math sum (addition)and subtract (subtraction) functions according to the requirements.


  • Calc.js should contain SumCtrl and SubCtrl controllers
  • SumCtrl should have an addition function assigned to itself
  • addition should consume two arguments and assign the result to sum variable
  • SubCtrl should be like SumCtrl but should have subtraction function and should have the result assigned to sub variable instead
  • each controller should have two variables (firstNumber, secondNumber) initialized with values 12 and 1
  • use addition and subtraction functions to display the result in the correct header (check comments)

Before you start, please refer to


To install dependencies

npm install

bower install

To start application in live reload mode

grunt serve


To run jshint:

grunt jshint:default

Run tests

To run unit tests in development mode:

grunt test:dev

To run jshint, tests and coverage:

npm test

Good luck!

Start this test

Labnoratory Academy Ltd (Realskill) is a Data Controller. Personal data will be processed to facilitate IT skill test. More
... Przewidywane kategorie odbiorców danych: pracownicy Bulldogjob oraz Labnoratory Academy Ltd. Podmiotowi danych przysługuje prawo do żądania dostępu do danych dotyczących swojej osoby, ich sprostowania, usunięcia, ograniczenia przetwarzania, do przenoszenia danych oraz wniesienia skargi do organu nadzorczego.
Go to the top and begin