$ scope变量不在视图中呈现

时间:2017-05-17 02:49:49

标签: angularjs

我开始使用angularjs并开始研究一个简单的例子。总的来说,到目前为止我还没有遇到过大的挑战,但是这个我无法弄明白......我有一些$ scope变量定义如下:

    'use strict';
angular.module('portalApp')
    .controller('summaryController', ['$scope', function ($scope) {
        $scope.todayProduction = '8';
        $scope.yesterdayProduction = '20';
        $scope.monthlyProduction = '500';
        $scope.dockedVessels = '16';
    }]);

这是我的观点html

<div class="row">
    <div class="col-md-3 col-sm-6">
        <div class="panel panel-default">
            <div class="panel-body">
                <div>
                    <span class="glyphicon glyphicon-stats" style="font-size: 50px;float: right;"></span>
                    <div>Today's Production</div>
                    <div style="font-size: 24px;">{{todayProduction}}<span style="font-size: 12px;"> tons</span></div>
                </div>
            </div>
        </div>
    </div>
    <div class="col-md-3 col-sm-6">
        <div class="panel panel-default">
            <div class="panel-body">
                <div>
                    <span class="glyphicon glyphicon-stats" style="font-size: 50px;float: right;"></span>
                    <div>Yesterdays's Production</div>
                    <div style="font-size: 24px;">{{yesterdayProduction}}<span style="font-size: 12px;"> tons</span></div>
                </div>
            </div>
        </div>
    </div>
    <div class="col-md-3 col-sm-6">
        <div class="panel panel-default">
            <div class="panel-body">
                <div>
                    <span class="glyphicon glyphicon-stats" style="font-size: 50px;float: right;"></span>
                    <div>Monthly Production</div>
                    <div style="font-size: 24px;">{{monthlyProduction}}<span style="font-size: 12px;"> tons</span></div>
                </div>
            </div>
        </div>
    </div>
    <div class="col-md-3 col-sm-6">
        <div class="panel panel-default">
            <div class="panel-body">
                <div>
                    <span class="glyphicon glyphicon-stats" style="font-size: 50px;float: right;"></span>
                    <div>Docked Vessels</div>
                    <div style="font-size: 24px;">{{dockedVessels}}<span style="font-size: 12px;"> tons</span></div>
                </div>
            </div>
        </div>
    </div>
</div>

问题在于,渲染时我看到了符号预期的字形,但是我没有显示变量值,而是{&variableName}}&#34;对所有人来说。

作为背景,我使用的示例项目最初是1.5版本,但我运行的是1.6

先谢谢你的帮助!!

1 个答案:

答案 0 :(得分:0)

在您的HTML中将 {{monthlyProduc tion}} 更改为 {{monthlyProduction}}