为什么我得到"错误:[ng:areq] http://errors.angularjs.org/1.3.5/ng/areq?p0=GreetingController&p1=not%20a%20function%2C%20got%20undefined& #34;

时间:2015-01-05 22:08:06

标签: javascript angularjs

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.5/angular.min.js"></script>
<script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.3.0.min.js"></script>


<html>
    <script>
        var myApp = angular.module('myApp', []);

        myApp.controller('GreetingController', ['$scope', function ($scope) {
            $scope.greeting = 'Hola!';
        }]);

    </script>

    <body ng-app>
        {{1+2}}
        <div ng-controller="GreetingController">
            {{ greeting }}
        </div>
</body>
</html>

你能向我解释为什么它会给我 错误:[ng:areq] http://errors.angularjs.org/1.3.5/ng/areq?p0=GreetingController&p1=not%20a%20function%2C%20got%20undefined

1 个答案:

答案 0 :(得分:1)

您需要添加ng-app="myApp"

有关ngApp指令here

的更多信息