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,

1 Answer 1

6

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

Sign up to request clarification or add additional context in comments.

1 Comment

@PGriep, don't. Silly mistakes are normal in programming. JavaScript lets you do more than some languages without alerting you too. I was accidentally assigning a value not to $scope.value the other day but directly to $scope, which suddenly meant that the $scope wasn't working correctly anywhere :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.