$ scope를 통해 내 변수에 두 개의 변수를 전달하는 컨트롤러가 있습니다. 보기에 해당 변수를 표시 할 수 있습니다.지시어에 범위가 표시되지 않습니다.
필자는 필자가 지시어를 사용하여 지시어 범위에 두 변수를 전달한다. 여기
.directive('notes', function(){
return {
restrict: 'E',
templateUrl:'views/directives/notes-tpl.html',
scope:{
time:'=',
unit:'='
},
controller:['$scope',function($scope){
console.log('Current Time Stamp: ' + $scope.time);
console.log('Current Unit Stamp: ' + $scope.unit);
};
}]
};
})
내 HTML입니다 :
<notes time='currentTimeStamp' unit='currentUnitStamp'></notes>
문제는 내을 console.log() 그들에게 정의되지 않은 표시이다는
여기 내 지시어이다. 귀하의 예를 들어 새로운 추측 본 후
<!-- NOTES MODAL -->
<script type="text/ng-template" id="notesModal.html">
<div class="modal-header">
<a class="close" data-dismiss="modal" aria-label="Close" ng-click="close()"><span aria-hidden="true">×</span></a>
<h3 class="modal-title">Notes</h3>
</div>
<notes currentTimeStamp='{{currentTimeStamp}}' currentUnitStamp='{{currentUnitStamp}}'></notes>
</script>
여기 잘 작동 : http://plnkr.co/edit/lXctOKdJvqsy4zhVqhCk?p=preview. 당신의 속성에 가치가 있는지 * 확실합니까? – Claies
@ Claies, 그건 이상합니다. 지시어가있는보기에서 범위 결과를 표시하므로 컨트롤러에서보기로 연결되는 것을 알 수 있습니다. 그러나 내 console.log에 정의되지 않은 상태로 표시됩니다. – cnak2
Claeis가 한 일을 수행하십시오 : 문제를 재현하는 완전한 최소 예를 게시하십시오. 그렇게하는 동안 자신의 실수를 발견하게 될 것입니다. –