Uncaught ReferenceError: app ist nicht definiert Angularjs

Bekam ich diese Fehlermeldung. Ich schaute durch die Antworten bisher aber ich habe noch das gleiche problem.

index.html

<html lang="en" ng-app="customersApp">
<head>

    <link rel="shortcut icon" href="img/favicon.html">

    <title>Vizavoo</title>

    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/bootstrap-reset.css" rel="stylesheet">
     <link href="assets/font-awesome/css/font-awesome.css" rel="stylesheet" />

    <!--external css-->
   <link href="css/slidebars.css" rel="stylesheet">
    <!-- Custom styles for this template -->
    <link href="css/style.css" rel="stylesheet">
    <link href="css/style-responsive.css" rel="stylesheet" />


</head>

  <body>

   <div ng-view></div>



    <!-- js placed at the end of the document so the pages load faster -->
       <script src="scripts/angular.js"></script> 
       <script src="scripts/angular-route.js"></script>
         <script src="app/app.js"></script>
         <script src="app/controllers/loginController.js"> </script>
           <script src="js/jquery.js"></script>
    <script src="js/bootstrap.min.js"></script>



  </body>

<!-- Mirrored from thevectorlab.net/flatlab/login.html by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 08 Dec 2014 06:09:06 GMT -->
</html>

app.js

(function(){

var app= angular.module('customersApp',['ngRoute']);

app.config(['$routeProvider',
  function ($routeProvider) {
        $routeProvider.
        when('/login', {
            title: 'Login',
            controller: 'loginController',
               templateUrl: 'app/views/loginuser.html'
        })
            .when('/logout', {
                title: 'Logout',
                templateUrl: 'partials/login.html',
                controller: 'loginController'
            })

            .when('/dashboard', {
                title: 'Dashboard',
                templateUrl: 'app/views/dynamic_table.html',
                controller: 'loginController'
            })
            .when('/signup', {
                title: 'Signup',
                templateUrl: 'app/views/registration.html',
                controller: 'loginController'
            })

            .otherwise({
                redirectTo: '/login'
            });
  }]);

}());

loginController.js

app.controller('loginController', function ($scope,$http, Data) {
    //initially set those objects to null to avoid undefined error
    $scope.login = {};
    $scope.signup = {};
    $scope.doLogin = function (customer) {


        $.post("http://dev.miniluxe.com:4002/email_login",
  {

     email : $scope.login.email,
      password : $scope.login.password
  },
  function(data,status){


      data = JSON.parse(data);
      console.log(data);

      if(data.log==1)
      {

          //window.location.href = "dashboard";
           $location.path('dashboard');
      }
      else
      {


         alert("wrong username and password");
      }


  });


    };

    $scope.logout = function () {
        Data.get('logout').then(function (results) {
            Data.toast(results);
            $location.path('login');
        });
    }
    app.filter('startFrom', function() {
    return function(input, start) {
        if(input) {
            start = +start; //parse to int
            return input.slice(start);
        }
        return [];
    }
});






});

Bitte überprüfen Sie den code und mir sagen, wo ich bin, einen Fehler zu machen.

  • Warum sind Sie auf der Verpackung Ihrer app.js code in einer anonymen Funktion?
  • Ich lese die natürlich von Dan wahlin....Sie haben das so gemacht, damit ich Folgen, Ihre Methode
  • Das ist nicht erforderlich. Das zu tun ist, einschränken Gültigkeitsbereich von Variablen app nur auf diese Funktion und Sie versuchen, zu verwenden, die in einer anderen Datei. Entfernen Sie einfach, dass die anonyme Funktion ausgeführt wird.
  • danke, problem wurde gelöst, zeigt aber einen anderen Fehler: [$Injektor:unpr] Unbekannt-Anbieter: Datenprovider <- Daten
  • Ich habe da in meiner Antwort unten, entfernen Sie bitte Data Abhängigkeit von Ihrem controller Abhängigkeit Injektionen. Es gibt noch mehr Dinge, die fix im code. Schauen Sie sich deshalb meine Antwort.
InformationsquelleAutor Prince | 2014-12-31
Schreibe einen Kommentar