参数'AppCtrl'不是函数,未定义 - $ http angular-ionic error

Mat*_*kin 4 javascript angularjs ionic-framework

我试图建立一个简单的$ http应用程序,使用angularjs从离子框架上的json文件中获取数据.

这是我得到的错误:

错误:[ng:areq]参数'AppCtrl'不是函数,未定义http://errors.angularjs.org/1.2.12/ng/areq?p0=AppCtrl&p1=not%20aNaNunction%2C%20got%20undefined at file:/// C:/Users/Matan/tabapp/www/lib/ionic/js/ionic.bundle.js:9007:12 at assertArg(file:/// C:/ Users/Matan/tabapp/www/lib/ionic/js/ionic.bundle.js:10292:11)assertArgFn(file:/// C:/Users/Matan/tabapp/www/lib/ionic/js/ionic.bundle.js:10302:3 )在file:/// C:/Users/Matan/tabapp/www/lib/ionic/js/ionic.bundle.js:15706:9 at file:/// C:/ Users/Matan/tabapp/www/lib/ionic/js/ionic.bundle.js:15118:34 atEach(file:/// C:/Users/Matan/tabapp/www/lib/ionic/js/ionic.bundle.js:9239:20) at compositeLinkFn(file:/// C:/Users/Matan/tabapp/www/lib/ionic/js/ionic.bundle.js:15105:11)在compositeLinkFn上(文件:/// C:/ Users/Matan/tabLink/www/lib/ionic/js/ionic.bundle.js:14569:15)在compositeLinkFn上(file:/// C:/Users/Matan/tabapp/www/lib/ionic/js/ionic.bundle.js :14572:13)在compositeLinkFn上(file:/// C:/Users/Matan/tabapp/www/lib/ionic/js/ionic.bundle 的.js:14572:13)

我的代码是这样的:

<ion-view title="Dashboard">
  <ion-content class="has-header padding">
    <div ng-app="app1">
        <div ng-controller="AppCtrl">
          {{1 + 2}}
          <input type="text" ng-model="person.firstName" />
          <input type="text" ng-model="person.lastName" />
          <input type="button" ng-click="addPerson(person)" />

          <ul>
            <li ng-repeat="person in people">
                {{person.Name}} {{person.Description}}
            </li>
          </ul>
        </div>
    </div>
        <img class="Pageimg" src="img\Computer_Assistant.jpg"/>
        <h3>My Computer Can't Turn On</h3>
        <p>???? ?????? ?????? ???? ?? ???? ?????? ?????? ???? ?????? ????? ?????? ????? ?? 
        ????? ??????? ???"? ???? ???. ??? ??? ???? ????? "???" ?????? ??????? ????????? ??
        ?? ????, ???? ????? ????? ????? ???? ????. ???? ???? ?? ???, "??
        ??", ?????? ?????? ????? ????? ?????? ??????? ?? ??? ?????.</p>
    </div>
        <div>
        <img class="Pageimg" src="img\Computer_Assistant.jpg"/>
        <h3>My Computer Can't Turn On</h3>
        <p>???? ?????? ?????? ???? ?? ???? ?????? ?????? ???? ?????? ????? ?????? ????? ?? 
        ????? ??????? ???"? ???? ???. ??? ??? ???? ????? "???" ?????? ??????? ????????? ??
        ?? ????, ???? ????? ????? ????? ???? ????. ???? ???? ?? ???, "??
        ??", ?????? ?????? ????? ????? ?????? ??????? ?? ??? ?????.</p>
    </div>
        <div>
        <img class="Pageimg" src="img\Computer_Assistant.jpg"/>
        <h3>My Computer Can't Turn On</h3>
        <p>???? ?????? ?????? ???? ?? ???? ?????? ?????? ???? ?????? ????? ?????? ????? ?? 
        ????? ??????? ???"? ???? ???. ??? ??? ???? ????? "???" ?????? ??????? ????????? ??
        ?? ????, ???? ????? ????? ????? ???? ????. ???? ???? ?? ???, "??
        ??", ?????? ?????? ????? ????? ?????? ??????? ?? ??? ?????.</p>
    </div>
        <div>
        <img class="Pageimg" src="img\Computer_Assistant.jpg"/>
        <h3>My Computer Can't Turn On</h3>
        <p>???? ?????? ?????? ???? ?? ???? ?????? ?????? ???? ?????? ????? ?????? ????? ?? 
        ????? ??????? ???"? ???? ???. ??? ??? ???? ????? "???" ?????? ??????? ????????? ??
        ?? ????, ???? ????? ????? ????? ???? ????. ???? ???? ?? ???, "??
        ??", ?????? ?????? ????? ????? ?????? ??????? ?? ??? ?????.</p>
    </div>
  </ion-content>
</ion-view>
Run Code Online (Sandbox Code Playgroud)

和js文件:

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

app.controller('AppCtrl', function( $scope, $http) {
    var app = this;
    $http.get('webtest.json')
      .success(function(data) {
        console.log(data);
        $scope.people = data;
      })

    app.addPerson = function(person) {

    }
})
Run Code Online (Sandbox Code Playgroud)

我试图在互联网上寻找答案,但他们都没有帮助我.

Has*_*que 10

确保您没有在代码中再次创建"app1"模块.第二个参数"[]"将创建新模块或覆盖前一个模块.

// create new module
var app = angular.module('app1', []);
Run Code Online (Sandbox Code Playgroud)

并且以下行将访问已创建的模块.

var app = angular.module('app1');
Run Code Online (Sandbox Code Playgroud)