没有任何东西出现在数据上

时间:2016-01-29 03:30:42

标签: javascript angularjs

由于某种原因,我的数据显示在main.html上时你可以看到我把数据放在一个表中..这是一个流星应用程序,所以不要担心它已经使用节点安装了角度,因为我也我的电脑上有流星。我关注了this教程

main.html中:

<body>
<div ng-controller="PartiesListCtrl">
   <table border = 1>
       <tr ng-repeat = "data in parties">
           <td>{{data.name}}</td>
           <td>{{data.description}}</td>
       </tr>
   </table>
</div>
</body>

的index.html:

<body ng-app="socially">
<div ng-include src="'main.html'"></div>
</body>

app.js:

if (Meteor.isClient) {
    angular.module('socially', ['angular-meteor']);

    angular.module('socially').controller('PartiesListCtrl',["$scope", function ($scope) {
        $scope.parties = [
            {
                'name': 'Dubstep-Free Zone',
                'description': 'Can we please just for an evening not listen to dubstep.'
            },
            {
                'name': 'All dubstep all the time',
                'description': 'Get it on!'
            },
            {
                'name': 'Savage lounging',
                'description': 'Leisure suit required. And only fiercest manners.'
            }
        ];
    }]
   );
}

1 个答案:

答案 0 :(得分:2)

您的代码应如下所示。

angular.module('socially', ['angular-meteor'])
.controller('PartiesListCtrl',["$scope", function ($scope) {
        $scope.parties = [
            {
                'name': 'Dubstep-Free Zone',
                'description': 'Can we please just for an evening not listen to dubstep.'
            },
            {
                'name': 'All dubstep all the time',
                'description': 'Get it on!'
            },
            {
                'name': 'Savage lounging',
                'description': 'Leisure suit required. And only fiercest manners.'
            }
        ];
    }]
   );

<强>更改

删除angular.module的第二个实例('socially')并直接使用.controller或将其分配给某个变量,然后使用如下控制器。

var socially = angular.module('socially', ['angular-meteor']);
socially.controller('PartiesListCtrl',["$scope", function ($scope) {
 //Your controller code goes here.
}]);

如果它不起作用,请告诉我。

angular.module('socially', [])
.controller('PartiesListCtrl',["$scope", function ($scope) {
        $scope.parties = [
            {
                'name': 'Dubstep-Free Zone',
                'description': 'Can we please just for an evening not listen to dubstep.'
            },
            {
                'name': 'All dubstep all the time',
                'description': 'Get it on!'
            },
            {
                'name': 'Savage lounging',
                'description': 'Leisure suit required. And only fiercest manners.'
            }
        ];
    }]
   );
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="socially">
<div ng-controller="PartiesListCtrl">
   <table border = 1>
       <tr ng-repeat = "data in parties">
           <td>{{data.name}}</td>
           <td>{{data.description}}</td>
       </tr>
   </table>
</div>
</body>