End a call. factory in the function should not have any meaning. I think you must have made other changes as well.
In the third code snippet, when you call .module with two parameters, you create a new module. This would replace the module you created in "Code A" or "Code B".
You do not use the same module, but create a new one. Therefore, it makes sense that your UserService does not exist in the new module.
Your last fragment should call .module('BinD') with only one parameter. Just the name of the module you want to use.
angular .module('BinD') .controller('SignUpCtrl', function ($scope, $window, UserService) {
Another option is that you only .module once and save it.
var app = angular.module('BinD', ['ngSails']);
You can then call app.controller or app.factory without worrying about the syntax.
source share