Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AngularJS ui视图返回空白_Javascript_Angularjs_Uiview_Angular Ui Router - Fatal编程技术网

Javascript AngularJS ui视图返回空白

Javascript AngularJS ui视图返回空白,javascript,angularjs,uiview,angular-ui-router,Javascript,Angularjs,Uiview,Angular Ui Router,我正在尝试设置一个简单的登录屏幕。为什么这是空白的 index.html <!DOCTYPE html> <html > <head> <title>Joe Kleckler</title> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge">

我正在尝试设置一个简单的登录屏幕。为什么这是空白的

index.html

<!DOCTYPE html>
<html >
    <head>
        <title>Joe Kleckler</title>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link href="./css/bootstrap.min.css" rel="stylesheet">
    </head>
    <body ng-app="kleckDev">
        <div ui-view></div> 
    </body>
    <script src="./app/angular.min.js"></script>
    <script src="./app/ui.router.js"></script>
    <script src="./app/kleckDev.js"></script>

    <script src="./app/controllers/loginController.js"></script>
    <script src="./app/controllers/realmController.js"></script>
    <!--<script src="./app/bootstrap.min.js"></script>-->
    <script type="text/javascript">
        console.log("angular object", angular);
    </script>
</html>
loginController.js

app.controller("LoginController", ['$scope', '$http', '$state', function($scope, $http, $state) {

    $scope.registration = {
        firstName: undefined,
        lastName: undefined,
        email: undefined,
        username: undefined,
        password: undefined,
        checkPass: undefined
    }

    $scope.login = {
        username: undefined,
        password: undefined
    }

    $scope.registerUser = function() {
        var data = {
            firstName: $scope.registration.firstName,
            lastName: $scope.registration.lastName,
            email: $scope.registration.email,
            username : $scope.registration.username,
            password : $scope.registration.password,
            checkPass : $scope.registration.checkPass,
            access: 0

        }

        $http.post("php/register.php", data).success(function(response) {
            console.log(response);
            localStorage.setItem("user", JSON.stringify({user: response}));
            $state.go("realm");
        }).error(function(error) {
            console.log(error);
        });
    };

    $scope.loginUser = function() {
        var data = {
            username: $scope.login.username,
            password: $scope.login.password
        }

        $http.post("php/login.php", data).success(function(response) {
            console.log(response);
            localStorage.setItem("user", JSON.stringify({user: response[0].username}));
            $state.go("realm");
        }).error(function(error) {
            console.log(error);
        });
    }
}])
不到一个小时前它就出现了,我试图添加一些东西,但当我删除它时,因为它坏了,现在什么也看不出来


您的
index.html
文件已在应用程序目录中。因为它不加载angular或任何指定的文件,所以无法工作

从所有脚本源中删除
/app
目录

<script src="angular.min.js"></script>
<script src=".ui.router.js"></script>
<script src="controllers/loginController.js"></script>
<script src="controllers/realmController.js"></script>
<script src="kleckDev.js"></script>


最后加载
kleckDev.js
文件。

控制台中有什么错误?控制台中没有任何错误文件结构正确吗?视图已就位,控制器名称正确吗?我添加了文件结构的图像。它应该是正确的,在我尝试添加领域状态之前,它工作得很好,起初,它在那里,但找不到javascript文件。然后我添加了文件,就像我本来应该做的那样,然后什么都没有发生。在空白屏幕上,我继续删除领域状态和所有内容,仍然没有任何内容设置控制器的正确方法是什么?我需要先使用kleckDev.js,因为控制器使用了来自kleckDevI的模块。我也在帖子中添加了loginController.js。一切看起来都很好。您是否尝试重新排序index.html中的脚本?我编辑了我的答案。问题是,指定应用程序目录时index.html已经在应用程序目录中。这是不正确的,index.html在KlecklDev中,应用程序目录只是js文件
<script src="angular.min.js"></script>
<script src=".ui.router.js"></script>
<script src="controllers/loginController.js"></script>
<script src="controllers/realmController.js"></script>
<script src="kleckDev.js"></script>