2016-07-22 3 views
2

daterange를 사용하여 테이블을 필터링하려고하지만 모델을 업데이트 할 수 없어서 내가 선택한 날짜를 알 수 없습니다. Angular JS datepicker가 모델을 업데이트하지 않습니다.

는 날짜 선택기 팝업에 대한 HTML입니다 :

<label>From:</label> 
<p class="input-group" style="width:200px"> 
    <input type="text" class="form-control" uib-datepicker-popup = "{{format}}" ng-model="dt" is-open="status.opened" 
              min-date="minDate" max-date="maxDate" datepicker-options="dateOptions" date-disabled="disabled(date, mode)" 
              ng-required="true" close-text="Close"/> 
    <span class="input-group-btn"> 
      <button type="button" class="btn btn-default" ng-click="open($event)"><i class="glyphicon glyphicon-calendar"></i></button> 
    </span> 
</p> 

내 컨트롤러의 JS 코드 :

(function() 
{ 
'use strict'; 

angular.module('aml-tech-dashboard.successful-emails').controller('datepickerController', function ($scope) { 
    $scope.dt = ''; 
    $scope.status = { 
     opened: false 
    }; 

    $scope.format = "yyyy-MM-dd" 
    $scope.minDate = new Date(); 
    $scope.dateOptions = { 
     //formatYear: 'yy', 
     startingDay: 1 
    }; 

    $scope.open = function ($event) { 
     $scope.status.opened = true; 

    }; 

    }); 

})(); 

테이블 :

<tr ng-repeat = 'file in files | startFrom: dt'> 
+0

안녕하세요. Andreea. 나는 $ scope.dt가 $ scope 안에 어떤 값으로도 설정되어 있지 않다는 것을 알아 차렸다. $ watch function –

+0

안녕하세요, 저는 이것을 콘솔에 기록하고 다른 것을 선택할 때 변경 사항을 감지했는지 확인했습니다. 날짜. $ scope.dt에 값을 할당해도 아무 것도 바뀌지 않았습니다. – Andreea

답변

1

귀하의 tr 요소가 잘못된 것입니다.

<tr ng-repeat="file in files | startFrom: dt"></tr> 

또한 uib-datepicker-popup 지시문에 실수가 있습니다. 그것은 다음과 같아야합니다

uib-datepicker-popup="{{format}}" 

이 그것을 내장 각도 필터 아니므로 당신이 당신의 모듈에서 다른 곳 startFrom 필터를 정의 가정한다.

+0

고마워요, 변경 했는데도 여전히 모델을 업데이트하지 않습니다. 제 컨트롤러에 문제가 있다고 생각합니다 – Andreea

+0

어딘가에 'startFrom' 필터가 정의되어 있습니까? – Aron

+0

uib-datepicker-popup 지시문은 복사 붙여 넣기에 좋지 않습니다. – Andreea

0

이 시도 :

$scope.dt = new Date(); 

을하고 뷰 렌더링 할 때 컨트롤러가 호출되어 있는지 확인합니다.

관련 문제