为什么不能在指令Angular JS中使用两种绑定方式?
问题描述:
我用指令:为什么不能在指令Angular JS中使用两种绑定方式?
return {
restrict: 'E',
scope: {
isread: "=isread"
,....
templateUrl: 'list.html',
其中list.html是:
<div class="top-menu" ng-controller="NotificationController">
<notification-list isread="is_read"></notification-list>
</div>
而且NotificationController
:
scope.makeRead = function() {
$scope.is_read = true;
}
从那里我称之为指令
<span ng-show="isread"></span>
和家长trmplate
为什么当我在控制器中更改$scope.is_read = true;
时,在变量isread
中的指令中没有更改?
答
return {
restrict: 'E',
scope: {
isread: "="
,....
templateUrl: 'list.html',
+2
虽然此代码片段可能会解决问题,但[包括解释](http://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers)确实有助于提高帖子的质量。请记住,您将来会为读者回答问题,而这些人可能不知道您的代码建议的原因。 – DimaSan
如何在控制器中检查“is_read”正在更新为true? –
默认情况下它是:'$ scope.is_read = false'在控制器中 – Daniel
检查控制器中的$ scope.is_read是否更新为true –