I created a common service to share the data between controller.

Below is the code snippet.

Here am getting undefined while using setter and getter. While accessing the object directly am getting the value. How to get the values using getter and setter.

what happens behind the scenes here.

```js
// JavaScript source code

(function () {
    'use strict';

    angular.module('app',[])

})();

(function () {
    'use strict';

    angular
      .module('app')
      .factory('appcontext', appContext);

    function appContext() {
        var service = {            
            getStartDate: getStartDate,         
          setStartTime : setStartTime,
            startTime : startTime

        };

        return service;

        //private variables       

        var startTime = '';

        function setStartTime(startTime) {
            startTime = startTime;
        }

        function getStartDate() {
            return startTime;
        }      

    }
})();

(function () {
    'use strict';

    angular.module('app')
           .controller("InsController", InsController)

    InsController.$inject = ['appcontext'];

    function InsController(appcontext) {

        appcontext.setStartTime(new Date());

        console.log(appcontext.getStartDate()); // undefined

        appcontext.startTime = new Date();

        console.log(appcontext.startTime); //prints the date correctly

    }          

})();
```

```html
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<html ng-App="app">

  <div ng-controller= "InsController">

    <div>{{ }}</div>

    </div>

  </html>
```