获取错误角度参数'mainController'不是函数,未定义

时间:2015-12-31 05:14:50

标签: angularjs

    <div ng-app = "myApp" ng-controller = "mainController">

             <table border = "0">
                <tr>
                   <td>Enter first name:</td>
                   <td><input type = "text" ng-model = "student.firstName"></td>
                </tr>

                <tr>
                   <td>Enter last name: </td>
                   <td><input type = "text" ng-model = "student.lastName"></td>
                </tr>

                <tr>
                   <td>Name: </td>
                   <td>{{student.fullName()}}</td>
                </tr>

             </table>

          </div>

var myApp = angular.module("myApp", []);

myApp.controller("mainController", function($scope) {
   $scope.student = {
      firstName: "Mahesh",
      lastName: "Parashar",
      fees:500,

      subjects:[
         {name:'Physics',marks:70},
         {name:'Chemistry',marks:80},
         {name:'Math',marks:65},
         {name:'English',marks:75},
         {name:'Hindi',marks:67}
      ],

      fullName: function() {
         var studentObject;
         studentObject = $scope.student;
         return studentObject.firstName + " " + studentObject.lastName;
      }
   };
});

我遇到了这个代码的问题,它说错误“Argument'mainController'不是一个函数,未定义”我无法理解它为什么这么说。任何人都可以解释同样的我在angularjs中是非常新的。

1 个答案:

答案 0 :(得分:0)

它应该根据您提供的信息工作。

这是工作Plunker应用程序