Services in angularJS not working in controller

8 views
Skip to first unread message

Stanislav

unread,
Jan 27, 2019, 8:19:03 AM1/27/19
to Angular and AngularJS discussion
Hi, Everybody. I Have a  stupid problem with a services. Why they always undefined? I Use one of latest version of angularJS 1.7.6.


var app = angular.module("appTestApp", []);
app.service('Calculator', function () {
this.square = function () {
console.log("This is service")
};
});


app.run(function ($transitions, $state) {
$transitions.onStart({}, function(transition, $state, toState, $rootScope, Calculator){


console.log(Calculator)

        Calculator.square()



});
});


And I have such result in console.


How I connect the libraries

Can anybody help me

Reply all
Reply to author
Forward
0 new messages