小编ged*_*edq的帖子

为什么我的Angular控制器未定义?

我一直在关注一个教程,教科书向我保证这是有效的,但它是轰炸

错误:[ng:areq]参数'SimpleController'不是函数,未定义

为什么?我已经弄明白了,上下都有,我看不出问题.为什么会SimpleController出现未定义的?

<html ng-app>
<head>
    <title>
    </title>
</head>
<body>
    <input type="text" ng-model="blah" />

    <div ng-controller="SimpleController">
        <h3>looping a data set</h3>
        <ul>
            <li ng-repeat="cust in customers | filter:blah | orderBy:'city'">
                {{cust.name | uppercase}} - {{cust.city | lowercase}}
            </li>
        </ul>
    </div>

    <script src="angular.js"></script>
    <script>
        function SimpleController($scope)
        {
            $scope.customers = [
                {name: 'John Smith', city: 'Phoenix'},
                {name: 'Jane Smith', city: 'Pittsburgh'},
                {name: 'John Doe', city: 'New York'},
                {name: 'Jane Doe', city: 'Los Angeles'}
            ];
        }
    </script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

3
推荐指数
2
解决办法
7495
查看次数

标签 统计

angularjs ×1

javascript ×1