한 페이지에 2 개의 지시문이 있습니다. 첫 번째는 정상적으로 작동하지만 두 번째는 작동하지 않습니다.각도 제 2 지시문이 작동하지 않습니다.
<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();
});
}
}
})
그러나 두 번째 지침은 표시되지 않습니다
HTML :
이 내 코드입니다. 내가 뭘 잘못하고 있니?
실수로 죄송합니다. 나는 지시어를 복사하는 것을 잊는다. 지금 생각
(있는 경우) 두 지침에 대한 코드를 제공해야합니다. 그렇지 않으면 귀하의 질문은 실제로 완료되지 않습니다 ... – Ivica
미안 해요, 나는 복사 지시문을 복사하는 것을 잊지. – Dimitris