2017-03-09 8 views
1

私はディレクティブを使用します。Angular JS指令で2つのバインド方法が動作しないのはなぜですか?

するlist.htmlは
return { 
    restrict: 'E', 
    scope: { 
     isread: "=isread" 
    ,.... 
    templateUrl: '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のディレクティブに変更されませんか?

+0

「is_read」がtrueに更新されていることをコントローラでどのようにチェックしましたか? –

+0

デフォルトではコントローラ内に '$ scope.is_read = false'があります – Daniel

+0

コントローラで$ scope.is_readがtrueに更新されているかどうか確認してください –

答えて

0
return { 
restrict: 'E', 
scope: { 
    isread: "=" 
,.... 
templateUrl: 'list.html', 
+2

このコードスニペットは問題を解決するかもしれませんが、[説明を含む](http://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers)は本当にあなたの投稿の質を向上させるのに役立ちます。将来読者の質問に答えていることを覚えておいてください。そうした人々はあなたのコード提案の理由を知らないかもしれません。 – DimaSan

関連する問題