AngularJS模块无法加载

P G*_*iep 3 html javascript debugging module angularjs

我的模块没有加载,我无法弄清楚原因.有人能帮助我找出我做错了什么吗?

以下是我在名为index.html的文件中的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>
Run Code Online (Sandbox Code Playgroud)

这是名为_Script.js的文件中的Javascript:

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

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

demoApp.controller('SimpleController', SimpleController);
Run Code Online (Sandbox Code Playgroud)

我找了一切,所以也许这很简单.但是我找不到它并且坚持下去.

问候,

小智 6

你现在首先加载你的_script.js,然后加载角度JS.如果你重新排序它们你的脚本应该工作:

  • @PGriep,不要.愚蠢的错误在编程中是正常的.JavaScript允许您执行多种语言而不会提醒您.前几天我不小心为$ scope.value分配了一个值而是直接分配给$ scope,这突然意味着$ scope在任何地方都无法正常工作:) (2认同)