离子:双花括号" {{"没有评估

时间:2015-07-03 08:32:09

标签: html angularjs web ionic

我有一个HTML文件,其中我试图从控制器显示变量,如下所示:

<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/services.js"></script>
<body ng-app="starter">
      <ion-pane>

          <ion-content ng-controller="ListCtr”>
              {{var}}      <!-- this is not evaluated! -->
          </ion-content>

      </ion-pane>
  </body>

输出很简单:{{scope.var}} 而不是Hello!

controllers.js文件:

angular.module('starter.controllers', [])

.controller('DashCtrl', function($scope) {})

.controller('ChatsCtrl', function($scope, Chats) {

            $scope.chats = Chats.all();
            $scope.remove = function(chat) {
            Chats.remove(chat);
            }
            })

.controller('ChatDetailCtrl', function($scope, $stateParams, Chats) {
            $scope.chat = Chats.get($stateParams.chatId);
            })

.controller('AccountCtrl', function($scope) {
            $scope.settings = {
            enableFriends: true
            };
            })


<!-- ** This the controller, which has the referenced var ** -->
.controller('ListCtr', function ($scope) {
            $scope.var = "Hello!";
            })
;

任何人都可以指出我做错了吗?

1 个答案:

答案 0 :(得分:1)

您绑定var$scope,然后您可以直接在相应的视图中引用它。删除html中的scope

 <ion-content ng-controller="ListCtr”>
    {{var}}
 </ion-content>