我为糟糕的格式道歉。基本上," clientCount"在我的屏幕上显示为{{clientCount}},而不是整数' 10'。有任何想法吗?谢谢!
var app = angular.module('metaDashboard', []);
/**This is for the meta-dashboard home page
*/
app.controller('TotalNumberController', ['$scope', function($scope) {
$scope.clientCount = '10';
$scope.campaignCount = '20';
$scope.accountCount = '10';
$scope.userCount = '100';
}
]);
--------------------------------------------------------------------
<html lang="en" ng-app="app">
<body class="page-body" data-url="http://neon.dev" ng-app="app">
<div class="row" ng-controller="TotalNumberController">
<div class="icon"><i class="entypo-globe"></i></div>
<div class="num"> {{clientCount}} </div>
<h3>Clients</h3>
<p></p>
</div>
</body>
</html>
答案 0 :(得分:2)
您的应用名为metaDashboard
而非app
,您应将代码更改为以下内容:
<html lang="en" ng-app="metaDashboard">
同时确保您的头部中包含angular.js
个文件。
完整代码段
var app = angular.module('metaDashboard', []);
app.controller('TotalNumberController', ['$scope', function($scope) {
$scope.clientCount = '10';
$scope.campaignCount = '20';
$scope.accountCount = '10';
$scope.userCount = '100';
}
]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.1/angular.js"></script>
<script src="script.js"></script>
</head>
<body ng-app="metaDashboard">
<div ng-controller="TotalNumberController">
<h1>{{clientCount}}</h1>
</div>
</body>
</html>
我还在此处加入了 Plunker ,以证明其有效:
https://plnkr.co/edit/t80RjCqjmE3y9bOkESo0?p=preview
作为补充说明,最好使用ViewModel语法而不是$scope
,我认为这是最佳做法,如果您嵌套了AngularJS控制器,可能会对您有所帮助。