3

My module isn't loading, and I can't figure out why. Could someone help me to find out what I am doing wrong?

The following is my HTML in a file named index.html:

<html ng-app="demoApp">
    <head>
        <title>Using AngularJS Directives and Data Binding</title>
        <script type="text/javascript" src="_Script.js"></script>
        <script src="angular.min.js"></script>
    </head>
    <body>
        <!-- Get name out of array with controller using a module-->
        <h3>Get names out of an array with controller using a module:</h3>
        <div class ="container" ng-controller="SimpleController">
            <input type="text" ng-model="search" /> {{ search }}
            <ul>
                <li ng-repeat="naam in namen | filter:search" >{{ naam }}</li>
            </ul>   
        </div>
    </body>
</html>

And this is the Javascript in a file named _Script.js:

var demoApp = angular.module('demoApp', []);

function SimpleController($scope) {
    $scope.namen = [
        'John', 
        'Will', 
        'Alex'
    ];
}

demoApp.controller('SimpleController', SimpleController);

I've looked for everything, so maybe it is simple. But I can't find it and got stuck with it.

Regards,

4

1 回答 1

6

您当前首先加载 _script.js,然后加载 Angular JS。如果您对它们重新排序,您的脚本应该可以工作:

于 2013-05-24T11:49:50.983 回答