admin管理员组

文章数量:1356839

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,

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,

Share Improve this question edited May 24, 2013 at 11:50 P Griep asked May 24, 2013 at 11:43 P GriepP Griep 8442 gold badges14 silver badges26 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

You're currently loading your _script.js first, and angular JS second. If you reorder them your script should work:

本文标签: javascriptAngularJS module doesn39t loadStack Overflow