Error: [ng:areq] from angular controller

后端 未结 20 2139
攒了一身酷
攒了一身酷 2020-11-27 17:39

This is a long shot, but has anyone seen this error before? I am trying to add \'Transporters\' using express, angular and mongoDB. I get this error whenever I access a page

20条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 18:20

    // include controller dependency in case of third type

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

    // first type to declare controller // this doesn't work well

    var FirstController = function($scope) {
        $scope.val = "First Value";
    }
    

    //Second type of declaration

    app.controller('FirstController', function($scope) {
        $scope.val = "First Controller";
    });
    

    // Third and best type

    angular.module('controller',[]).controller('FirstController', function($scope) {
        $scope.val = "Best Way of Controller";
    });
    

提交回复
热议问题