Verification issue

I’m working on the login portion of my app but my verification service doesn’t seem to be working. I’m checking inputs for users email and password from the html page and using this ctrl with the button click

app.controller('Controller', ['$scope', '$ionicPopup', '$state', function($scope, $location, LoginService, $state, $ionicPopup, $timeout){

$scope.controller ={};
 $scope.controller.login = function() {

            LoginService.loginUser($, $scope.password).success(function () {

            }).error(function () {
                var alertPopup = $ionicPopup.alert({
                    title: 'Login failed!',
                    template: 'Please check your credentials!'

           console.log("Username: " + $ +  "Passowrd: " + $scope.password);


My service is

.service('LoginService', function() {
  return {
    loginUser: function(name, pw) {
      var deferred = defer();
      var promise = deferred.promise;

      if (name == 'user' && pw == 'secret') {
        deferred.resolve('Welcome ' + name + '!');
      } else {
        deferred.reject('Wrong credentials.');
      promise.success = function(fn) {
        return promise;
      promise.error = function(fn) {
        promise.then(null, fn);
        return promise;
      return promise;

and my state is just

.state('login', {
    url: '/Login.html',
    templateUrl: 'views/login.html'

I’ve gotten this service to work before but when I integrated it into my app it suddenly stopped functioning. I’ve been trying to fix this for a while now so any help would be greately appreciated.

Have you read the error on console? What does it say?

I believe you are doing something wrong here:

// Fixed and removed $timeout and $location because you are not using them. at least in this example.
app.controller('Controller', [
        '$scope', 'LoginService', '$state', '$ionicPopup',
function($scope,   LoginService,   $state,   $ionicPopup){

Also, it would be better if you use .then(successCallback, errorCallback).