Javascript 无法管理角度相关性

Javascript 无法管理角度相关性,javascript,html,angularjs,Javascript,Html,Angularjs,我开始学习angular,但我在管理依赖关系方面遇到了困难,我不明白这为什么不起作用 我的html: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" ng-app="client"> <head> <meta charset="utf-8" /> <title>Title</title> <link rel="styleshe

我开始学习angular,但我在管理依赖关系方面遇到了困难,我不明白这为什么不起作用

我的html:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" ng-app="client">
<head>
    <meta charset="utf-8" />
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="mainstyle.css">
    <script type="text/javascript" src="includes/files/angular.js"></script>
    <script type="text/javascript" src="includes/files/login/login-directives.js"></script>
    <script type="text/javascript" src="includes/files/logged/logged-directives.js"></script>
    <script type="text/javascript" src="includes/files/application.js"></script>
</head>
<body  ng-controller="ApplicationController as controller"> 

    <logged-content  ng-show="controller.isLogged"></logged-content>

    <login-content  ng-show="!controller.isLogged"></login-content>

</body>
</html>
})()

记录的指令:

(function(){
var app = angular.module('logged-directives', []);

app.directive('loggedContent', function(){
            return{
                restrict : 'E',
                templateUrl : 'logged-content.html',
            }
    });

});
(function(){
var app = angular.module('login-directives', []);

app.directive('loginContent', function(){
            return{
                restrict : 'E',
                templateUrl : "includes/files/login/login-content.html",
                controller: function($scope) {

                  this.validateLogin = function(user) {
                    alert("user:"+ user.login + " pass : "+user.password);
                    isLogged = true;
                    currentUser = user;
                  };

                },
                controllerAs: "review"
            }
    });

})();
登录指令:

(function(){
var app = angular.module('logged-directives', []);

app.directive('loggedContent', function(){
            return{
                restrict : 'E',
                templateUrl : 'logged-content.html',
            }
    });

});
(function(){
var app = angular.module('login-directives', []);

app.directive('loginContent', function(){
            return{
                restrict : 'E',
                templateUrl : "includes/files/login/login-content.html",
                controller: function($scope) {

                  this.validateLogin = function(user) {
                    alert("user:"+ user.login + " pass : "+user.password);
                    isLogged = true;
                    currentUser = user;
                  };

                },
                controllerAs: "review"
            }
    });

})();
在chrome中打开html文件时,出现以下错误:

错误:[$injector:nomod]模块“记录的指令”不可用! 您要么拼错了模块名,要么忘记加载它。如果 注册模块时,请确保将依赖项指定为 第二个论点

(我没有包括登录指令,因为它是相同的,不需要理解这个问题,我对登录指令也有同样的问题)

我错过什么了吗


谢谢你的帮助

请更新您创建指令的行:

app.directive('loggedContent', function(){ // L should be lower case

因为,您在html:)中使用了登录内容

我认为您正在与命名约定作斗争
这将对您有所帮助。

好的,我发现了问题。。。我忘了在指令文件的末尾添加“()”


谢谢您的帮助。

没有名为
loggedDirectives
的模块,您将其定义为
loggedirectives
。谢谢,我做了更改,但仍然出现错误。(我没有粘贴login-content.html和login指令,因为在没有这些文件/指令的情况下仍然会出现错误)。也许问题出在我的文件路径上。这很直截了当。如果您仍然面临错误,请告诉我(如果您创建一个小提琴的话会更好)。对于这个错误,这没关系!现在,我希望能够从位于login-content.html中的表单中更改“ApplicationController”'isLogged'值,我应该创建一个控制器来检查模板中的用户名/密码,连接到我的服务器,好的,我可以使用angular的文档管理它,但是该控制器如何更改“ApplicationController”是否为loggedContent指令创建单独的作用域?因为您没有为loggedContent指令创建单独的作用域,所以它将共享其父级的作用域。请更改如下:app.controller('ApplicationController',function($scope){$scope.isLogged=false;}.Now isLogged将可从其子指令访问。如果您希望在多个控制器之间共享变量,请使用Factory或Service。谢谢,我用您的答案更新了我的第一篇文章。我已成功获取我的登录表单内容(用户是一个对象,具有表单字段中的登录名和密码),然后我的想法是将isLogged更改为true,并等待我的索引刷新自身(nb show)属性。我是否缺少某些内容?我是否需要刷新索引,还是我使用了错误的方法?