0
사용자가 필드에 아무 것도 입력하지 않은 경우이 지시문에 의해 생성 된 입력 필드의 클릭에 대한 지시문을 제거하는 방법을 알아 내려고하고 있습니다. 현재 지시문은 아무 것도 입력되지 않는 경우를 제외하고는 계획대로 작동하는 것으로 보입니다. 기본적으로 입력 된 지시문이 제거되지 않고 어떤 함수가 호출 된 경우. 난 그냥 지시문 템플릿을 제거 싶어요. 감사.AngularJS는 clickaway에서 지시문을 제거합니다.
DocumentManager.directive('clickAway', function($compile,$document, $location){
return {
replace: true,
scope: true,
template:'<input type="text" class="form-control" ng-model="item.name" placeholder="Enter name">',
restrict: 'AE',
link: function(scope, elem, attr, ctrl) {
elem.bind('click', function(e) {
e.stopPropagation();
});
$document.bind('click', function() {
if(scope.item == null){
return;
};
scope.createItem(scope.item);
scope.item= null; });
}
}});
이것은 'ng-if'가 사용되는 이유입니다. – cgTag