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
更改为正确的遭遇。绑定不会将所选内容带到mychatContainer
。我想当我在指令作用域中声明遭遇
并将其作为作用域类型时,它绑定了它,但我缺少了一些东西 您需要$apply()
更改,但是操作值的逻辑应该在chatContainer指令内部,而不是在控制器内部 同意,它应该在指令中,但是$apply如何工作?调用函数getSelectedRow()
?您没有包含所有的代码,所以我猜angular框架之外有一些东西,因此$digest
循环没有运行。本文对此进行了很好的解释