0

行がクリックされたときに詳細画面を表示するディレクティブがあります。私は出会いを更新しようとしています。ディレクティブは次のとおりです。

angular.module('app').directive('chatContainer', function() {
  return {
    scope: {
      encounter: '=',
      count: '='
    },
    templateUrl: 'views/chat.container.html',
    link: function(scope, elem) {
  };
});

ディレクティブのテンプレートは次のとおりです。

<div class="span4 chat-container">
 <h5 class="chat-header">
  <span class="container">{{encounter.patient.firstName }} {{encounter.patient.lastName}}</span>
  </h5>
</div>

ディレクティブが html で宣言されている場所は次のとおりです。

<div chat-container encounter="selectedEncounter" count="count"></div>

行がクリックされたときに呼び出されるコントローラーは次のとおりです。

angular.module('app').controller('EncounterCtrl', function ($scope, singleEncounter) {

  $scope.count = 500;

  $scope.selectedIndex = -1;

  $scope.selectedEncounter = -1;

  $scope.getSelectedRow = function($index) {
    $scope.selectedIndex = $index;
    $scope.selectedEncounter = $scope.encounters[$scope.selectedIndex];
  };

  $scope.encounter = singleEncounter.selectedEncounter;
});

関数に入ると、正しい出会いgetSelectedRow()に変わります。selectedEncounterバインディングは、選択範囲を my に渡しませんchatContainerencounterディレクティブ スコープでを宣言し、それ=をスコープ タイプとして指定すると、それがバインドされると思いましたが、何か不足していますか???

4

1 に答える 1

0

変更する必要がありますが$apply()、値を操作するためのロジックは、コントローラー内ではなく、chatContainer ディレクティブ内にある必要があります。

于 2013-10-21T16:44:30.447 に答える