0

私のコントローラに複雑なデータモデルを作成することはできません。 コードを作成するたびに、コードは自動的に失敗するようです。angularjsデータバインディングが消える - サイレントに失敗する

$ scope.conversationList = [123456]; は両方ともng-bind &をディレクティブテンプレートで使用してうまく動作します。

私はそれらを{{conversationList.conversation}}に変更すると静かに失敗し、ngbindが空になり、テンプレートには平文で "{{conversationList.conversataion}}"と表示されます。

私は何が間違っているのか分かりません。私が見つけることができるすべての例は、モデルを正しくフォーマットしたように見えますが、それは失敗し続けます。

はあなたの助けをありがとう

コントローラ

/* global angular */ 
'use strict'; 


app.controller('conversationListCtrl', ['$scope', function ($scope) { 

    $scope.conversationList = [ 
     { 
      conversation2: 123456789, 
      conversation: 
       { 
        id: "bestbuy", 
        messageId: 123456, 
        subscriber: "Billy Madison", 
        subscriptionType: "summerPass", 
        conversationImage: "insert Image" 
       } 
     } 
    ] 
} 
]) 

.directive('listCtrl', function() { 

    return { 
     scope: false, 
     template: '<div> {{conversationList.conversation}} </div>' 
    } 
}); 

Index.htmlと

<!doctype html> 
<html ng-app="ChatApp" class="angularjs ng-scope"> 
<head> 
    <meta charset="utf-8"> 

    <title>ClearKey Test Message</title> 
    <meta name="description" content="Layer Angular example"> 

    <link rel="shortcut icon" href="http://static.layer.com/web/favicon.png"> 

    <link href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600" rel="stylesheet" type="text/css"> 
    <link href="http://fonts.googleapis.com/css?family=Raleway:300,400" rel="stylesheet" type="text/css"> 
    <link href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet" type="text/css"> 

    <!-- Common CSS and Identity dialog --> 
    <link href="common/style.css" rel="stylesheet"> 


    <!-- Layer Web SDK --> 
    <script src='vendors/layer-websdk.min.js'></script> 

    <script src='vendors/angular.js'> 
     //checked 
    </script> 
    <script src='vendors/angular-route.js'> 

    </script> 

    <script src='vendors/ng-infinite-scroll.min.js'></script> 
    <script src='vendors/stop-angular-overrides.js'></script> 
    <!-- Angular app --> 
    <script src='js/app.js'></script> 
    <script src="jquery-3.1.1.min.js"></script> 
    <script src="js/models/conversation.js"></script> 


</head> 

<body class="ng-scope" cz-shortcut-listen="true"> 
    <!-- ^^^used to have appCtrl^^^ --> 
    <div class="main-app" ng-include="'views/app.html'"></div> 


</body> 
</html> 

App.html

<div src="jquery-3.1.1.min.js"> 
    <!-- ^^^needs appctrl controller^^^ --> 
    <div class="messenger"> 
     <div class="left-panel"> 
      <div class="Message-item"> 
       <div class="imgContainer"> <img class="cornerImage" src="images/favicon.png" /> </div> 

      </div> 

      <div > 
       <!-- ^^^had the conversationListCtrl^^^ --> 
       <div class="panel-header conversations-header" 
        > 
       <!-- ^^^had the partials for the left column header^^^ --> 
       </div> 
       <div ng-controller="conversationListCtrl" class="conversation-list"> 
        <div list-Ctrl ></div> 
        <div ng-model="conversationList" class="conversation-list" style="border:dashed" ng-bind="{{conversationList.conversation}}"></div> 

       </div> 
       <!-- had the partials for conversationlist.html --> 
      </div> 
     </div> 
     <div class="right-panel" > 
      <div 

       > 
       <!-- had the partials for the messages that were in each conversation --> 
      </div> 
     </div> 
    </div> 
</div> 

答えて

0

はあなたがアクセスしたい要素を定義する必要があります - 交換する - {{conversationList.conversation.id}}または{{conversationList.conversation.messageId}}

+0

、私はそれはまだ静かに失敗し、何も入れなかったように、NG-バインドの内容を削除することを行う場合でも、その開始する - と{{conversationList.conversation}} を〜と – Siddartha

関連する問題