angularjs文件没有在firebug中显示

时间:2015-03-04 12:49:53

标签: angularjs firebug

你好我是angularjs的新手 而且我不确定我写的代码是否正确。 但由于某种原因,萤火虫没有在脚本列表中显示它。 有没有办法检查它之外的问题? 我真的可以使用它的帮助。

我的代码是附加的,以防它被显示损坏。 谢谢你的时间。

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

myapp.config(function($routeProvider){
$routeProvider
.when('/',{
       templateUrl : 'pages/home.html'
})
.when('/login',{
       templateUrl : 'pages/login.html',
       controller  : 'loginController'
    })
.when('/register',{
       templateUrl : 'pages/register.html',
       controller  : 'registerController'
    })
.when('/user',{
       templateUrl : 'pages/user.html',
       controller  : 'userController'
    })
.when('/logout',{
       controller  : 'logoutController'
    });
});
//global variable for logged user will be in a service
myapp.factory('LoggedUser',function(){
    var logged=null;
    return{
        getLogged=function(){
            return logged;
        }
        setLogged=function(name){
            logged=name;
        }
    }
});

myapp.controller('loginController',['$scope','$http','LoggedUser',function($scope,$http,LoggedUser){

    $scope.login=function(log){
        var url="login.php";

        //post the username & password 
        $http({
            method:'POST',
            url:url,
            data:{'username':log.username,
                  'password':log.password}
        })
        //handle response from the server
        .success(function (data){
            if(data=='ok')
            {
                 LoggedUser.setLogged(log.username); //set the current user
            }
        });
    };

}]);

myapp.controller('registerController',['$scope','$http','$window',function($scope,$http,$window){

    $scope.register=function(reg){
        $scope.passMatch=true;
        var url="register.php";
        if(reg.password!=reg.password2){ //passwords do not match.
            $scope.passMatch=false;
            }
        $http({
            method:'POST',
            url:url,
            data:{'regusername':reg.username,
                  'regpassword':reg.password}
            })
        //handle response from the server
        .success(function (data){
            if(data=='ok'){

                $window.alert("welcome, you may now log in");
            }
            else{
                $window.alert(data);
            }
        });//end http

    }; //end register
}]);//end registerController

myapp.controller('userController',['$scope','$http','$window',function($scope,$http,$window){
    $scope.games=null;
    $scope.users=null;
    $scope.selectedRow=null;
    //feel table
    $http({
        url: "getGames.php",
        method:"GET"
    }).success(function(data){
        $scope.games=data;
    }).error(function(data){
        $window.alert("could not fetch data");
    });//end http
    //get users
    http({
        url: "getUsers.php",
        method:"GET"
    }).success(function(data){
        $scope.users=data;
    }).error(function(){
        $window.alert("could not fetch data");
    });//end http

    $scope.setClickedRow=function(index){
        $scope.selectedRow=index;
    };

    $scope.deleteGame=function(index){
        $scope.games.splice(index,1);
    };

    $scope.sendFeed=function(game,user){
        http({
            url:"sendGame.php",
            method:"POST"
        }).success(function(data){
            if(data=="ok")
                $window.alert("game has been sended");
            else
                $window.alert("something went wrong");
        }).error(function(){
            $window.alert("could not connect to sendGame");
        });//end http
    };

}]);

myapp.controller('logoutController',['$http',function($http){// disconnect the user

    http({
        url: "logout.php",
        method:"GET"
    }).success(function(data){
        logged=null;
    });//end http

}]);

0 个答案:

没有答案