2016-07-29 15 views
0

1ページに2つのディレクティブがあります。最初のものは正常に動作しますが、2番目のものは動作しません。角度のある2番目のディレクティブが動作しない

これは私のコードです:

HTML

<body class="login" ng-app="Login"> 
<div ng-controller="HttpLoginController"> 
<wrongdetails></wrongdetails> 
<loading></loading> 
<input type="submit" ng-click="LoginUser()" value="Login" /> 
</div> 
</body> 

JS

var app = angular.module("Login", []) 
app.controller("HttpLoginController", function($scope,$http){ 
$scope.LoginUser = function(){ 
$scope.loading = true; 
var data = []; 
var config = {} 
$http.post('Mylink', data, config) 
.success(function (data, status, headers, config) { $scope.loading = false;}) 
.error(function (data, status, header, config) {$scope.wrongdetails = true; }); 
};  
}); 
//Directives 
app.directive('loading', function() { 
    return { 
     restrict: 'E', 
     //replace:true, 
     template: '<div id="loading"> <div class="progress-line"></div><br/> </div>', 
     link: function (scope, element, attr) { 
       scope.$watch('loading', function (val) { 
        if (val) 
         $(element).show(); 
        else 
         $(element).hide(); 
       }); 
     } 
    } 
}) 
app.directive('wrongdetails', function() { 
    return { 
     restrict: 'E', 
     replace:true, 
     template: '<div class="alert alert-danger display-hide"><button class="close" data-close="alert"></button><span> Error. </span></div>', 
     link: function (scope, element, attr) { 
       scope.$watch('wrongdetails', function (val) { 
        if (val) 
         $(element).show(); 
        else 
         $(element).hide(); 
       }); 
     } 
    } 
}) 

しかし、第二指令は表示されません。 私は間違っていますか?

私の間違いを犯して申し訳ありません。私は指示を貼り付けてコピーすることを忘れます。説明とその理由は、すでに提供されています

replace:true , 

- : 私は今

+0

(もしあれば)両方の指令のコードを提供する必要があります。それ以外の場合、あなたの質問は本当に完全ではありません... – Ivica

+0

申し訳ありませんが、私は指示を貼り付けてコピーすることを忘れないでください。 – Dimitris

答えて

関連する問題