2

I'm trying to run this AngularJS example of a tutorial and the console says: Uncaught Error: [$injector:modulerr]

Where is the problem?

<div class="container" data-ng-app="demoApp">
    <div>
        <h3>Adding Module Configuration and Routing</h3>

        <div data-ng-view=""></div>
    </div>
</div>

  <script src="angular-1.2.3/angular.min.js"></script>
  <script src="angular-1.2.3/angular-route.min.js"></script>

<script>
    var demoApp = angular.module('demoApp', ['ngRoute']);

    demoApp.config(function ($routeProvider) {
        $routeProvider
            .when('/',
                {
                    controller: 'SimpleController',
                    templateUrl: urlBase + '7. Partial1.html'
                })

            .when('/partial2',
                {
                    controller: 'SimpleController',
                    templateUrl: 'Partial/view1.html'
                })
            .otherwise({ redirectTo: '/' });
    });

    demoApp.controller('SimpleController', function ($scope) {
        $scope.customers = [
            { name: 'Dave Jones', city: 'Phoenix' },
            { name: 'Jamie Riley', city: 'Atlanta' },
            { name: 'Heedy Wahlin', city: 'Chandler' },
            { name: 'Thomas Winter', city: 'Seattle' }
        ];
    }); 
</script>
4
  • 4
    Are you using angular 1.2+? Have you included ngRoute javascript file? Commented Dec 3, 2013 at 22:34
  • Yes angular 1.2.3. I try with this: <script src="angular-1.2.3/angular.min.js"></script> <script src="angular-1.2.3/angular-route.min.js"></script> and It not works. The libraries are loading. Commented Dec 3, 2013 at 22:52
  • 2
    Get rid of the ="" in ng-view Commented Dec 3, 2013 at 22:55
  • @tymeJV put it as an answer :) Commented Feb 15, 2014 at 21:42

1 Answer 1

5

You need to remove the ="" from the ng-view attribute.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.