I wanna make "Go back when cancel btn clicked" function.
This is view code
<div ng-controller="goodCtrl">
<button class="btn" ng-click="cancel()">Cancel</button>
</div>
And this is Js code
1) controller
function goodCtrl($scope, $log, goodService)
$scope.cancel = function(){
$log.debug("goodCtrl - cancel");
goodService.cancel($scope);
};
2) service
function goodService($log, $state)
var methods = {
cancel: function($scope) {
$log.debug("goodService - cancel");
$state.go('goback');
}
}
3) module
angular
.module('goodmodule')
.controller('goodCtrl', goodCtrl)
.service('goodService', goodService)
But I got this problem
TypeError :
serviceName.functionName()
is not a function
Though there are so many controls, services, methods written like that, the service and controller that I added is unavailable. What is it that I missed?