Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/467.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新值未到达指令中_Javascript_Angularjs_Angularjs Directive_Angular Controller - Fatal编程技术网

Javascript AngularJS新值未到达指令中

Javascript AngularJS新值未到达指令中,javascript,angularjs,angularjs-directive,angular-controller,Javascript,Angularjs,Angularjs Directive,Angular Controller,我有一个模态的指令文件:login.component.js (function() { 'use strict'; var app = angular.module('myapp'); app.directive('loginComponent', ['loginService', function(loginService){ return { templateUrl: 'app/components/login/login

我有一个模态的指令<代码>文件:login.component.js

(function() {
    'use strict';

    var app = angular.module('myapp');

    app.directive('loginComponent', ['loginService', function(loginService){
        return {
            templateUrl: 'app/components/login/login.html',
            restrict: 'E',
            replace: true,
            controller: 'homeCrotroller',
            link: function ($scope) {
                $scope.submit = function() {
                    $scope.login();
                    $("#modal-login").modal('hide');
                };

                $scope.cancel = function() {
                    $scope.loggingIn = false;
                    $("#modal-login").modal('hide');
                };

                $scope.$watch('loggingIn', function() {                    
                    if ($scope.loggingIn) {
                        $("#modal-login").modal('show');
                    };
                });
            }
        };
    }]);

})();
(function() {
    'use strict';

    var app = angular.module('myapp');

    app.controller('homeCrotroller', ['$scope', function($scope){

        $scope.loggedIn = false;
        $scope.loggingIn = false;

        $scope.showLogin = function () {
            $scope.loggingIn = true;
        };

        $scope.logout = function () {
            $scope.user = null;
            $scope.loggedIn = false;
        };

        $scope.login = function () {
            $scope.loggingIn = false;
            $scope.loggedIn = true;
        };

    }]);

})();
和下一个控制器<代码>文件:home.controller.js

(function() {
    'use strict';

    var app = angular.module('myapp');

    app.directive('loginComponent', ['loginService', function(loginService){
        return {
            templateUrl: 'app/components/login/login.html',
            restrict: 'E',
            replace: true,
            controller: 'homeCrotroller',
            link: function ($scope) {
                $scope.submit = function() {
                    $scope.login();
                    $("#modal-login").modal('hide');
                };

                $scope.cancel = function() {
                    $scope.loggingIn = false;
                    $("#modal-login").modal('hide');
                };

                $scope.$watch('loggingIn', function() {                    
                    if ($scope.loggingIn) {
                        $("#modal-login").modal('show');
                    };
                });
            }
        };
    }]);

})();
(function() {
    'use strict';

    var app = angular.module('myapp');

    app.controller('homeCrotroller', ['$scope', function($scope){

        $scope.loggedIn = false;
        $scope.loggingIn = false;

        $scope.showLogin = function () {
            $scope.loggingIn = true;
        };

        $scope.logout = function () {
            $scope.user = null;
            $scope.loggedIn = false;
        };

        $scope.login = function () {
            $scope.loggingIn = false;
            $scope.loggedIn = true;
        };

    }]);

})();
在我看来,我调用
showLogin()



此函数将
$scope.logging
的值更改为
true
,只有此值未到达策略。仅到达第一个状态(加载屏幕),即
false

除了您两次拼写错误
homeCrotroller
之外,我看不出您的代码有任何错误。你确定你在
index.html
中同时使用
.js
文件吗?你在html文件中使用
吗?是的,我正在使用
。我正在用Grunt、Grunt Nganotate、Grunt contrib concat和UGLIFY生成javascript.min,当我更改变量$scope.logging的值为true并重新充电时,屏幕将正常工作,但单击交替,该值无效。