I'm trying to load angularJS with requireJS. But I always encountered this error:
Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.2.21/$injector/modulerr?p0=phoneApp&p1=Error%….org%2F1.2.21%2F%24injector%2Fnomod%3Fp0%3DphoneApp%0A%20%20%20%20at%20Err......7)
I have checked my code for many times, all scripts were loaded correctly, but can't get any idea about this error. The below is my code:
- index.html:
<body ng-app="phoneApp"> <div class="container" ng-controller="PhoneListCtrl"> <ul> <li ng-repeat="phone in phones">{{phone.name}}</li> </ul> </div> </body> <script src="bower_components/requirejs/require.js" data-main="scripts/main"></script>
- main.js
require.config({ paths : { jquery : '../bower_components/jquery/jquery.min', angular : '../bower_components/angular/angular.min' }, shim : { angular : { exports : 'angular' } } }); require(['jquery', 'angular'],function($, angular){ angular.module('phoneApp', []) .controller('PhoneListCtrl', function($scope){ $scope.phones = [ {'name': 'Nexus S', 'snippet': 'Fast just got faster with Nexus S.'}, {'name': 'Motorola XOOM™ with Wi-Fi', 'snippet': 'The Next, Next Generation tablet.'}, {'name': 'MOTOROLA XOOM™', 'snippet': 'The Next, Next Generation tablet.'} ]; }); });