Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我的控制器没有更新我的指令-Angular_Javascript_Angularjs - Fatal编程技术网

Javascript 我的控制器没有更新我的指令-Angular

Javascript 我的控制器没有更新我的指令-Angular,javascript,angularjs,Javascript,Angularjs,我有一个指令,当单击一行时显示详细信息屏幕。我正在尝试更新遭遇。以下是指令: angular.module('app').directive('chatContainer', function() { return { scope: { encounter: '=', count: '=' }, templateUrl: 'views/chat.container.html', link: function(scope, elem) {

我有一个指令,当单击一行时显示详细信息屏幕。我正在尝试更新遭遇。以下是指令:

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>
以下是该指令的模板:

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>

我进入函数
getSelectedRow()
,它将
selectedCounter
更改为正确的遭遇。绑定不会将所选内容带到my
chatContainer
。我想当我在指令作用域中声明
遭遇
并将其作为作用域类型时,它绑定了它,但我缺少了一些东西

您需要
$apply()
更改,但是操作值的逻辑应该在chatContainer指令内部,而不是在控制器内部

同意,它应该在指令中,但是$apply如何工作?调用函数
getSelectedRow()
?您没有包含所有的代码,所以我猜angular框架之外有一些东西,因此
$digest
循环没有运行。本文对此进行了很好的解释