Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
140 views
in Technique[技术] by (71.8m points)

javascript - Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.4.3/$injector/modulerr

Below is the error message i get for the code i have written. I have mention the code after the error message. I am new and need help!!

Uncaught SyntaxError: Unexpected token {angular.min.js:6

Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.4.3/$injector/modulerr?p0=mainApp&p1=Error%3A…A%2F%2Flocalhost%3A8084%2FAngularProject%2FLib%2Fangular.min.js%3A19%3A339)(anonymous function) @ angular.min.js:6(anonymous function) @ angular.min.js:38m @ angular.min.js:7g @ angular.min.js:37eb @ angular.min.js:40d @ angular.min.js:19Ac @ angular.min.js:20Zd @ angular.min.js:18(anonymous function) @ angular.min.js:289a @ angular.min.js:176c @ angular.min.js:35"

<script src="Lib/angular.min.js" type="text/javascript"></script>
        <script src="Lib/angular-route.js" type="text/javascript"></script>
        <script>
            var demoApp=angular.module('mainApp',[ngRoute]);

            demoApp.config(function($routeProvider){
                $routeProvider
                        .when('/',
                {
                    controller:'SimpleController',
                    templateUrl:'view1.html'
                })
                        .when('/view1',{
                            controller:'SimpleController',
                            templateUrl:'/view.html'
                })
                        .otherwise({redirectTo:'/'});
            });

            demoApp.controller('SimpleController',function($scope){
            $scope.customers=[
            {name:'Joe',city:'Toronto'},
            {name:'Jane',city:'Sydney'},
            {name:'Roberto',city:'Vienna'},
            {name:'Kumiko',city:'Japan'}
           ];

           $scope.addCustomer=funtion(){
             $scope.customers.push({name:$scope.newCustomer.name,city:$scope.newCustomer.city});  
           };
        });/*
            function SimpleController($scope){
                $scope.customers=[
                    {name:'Sabin',city:'Bhaktapur'},
                    {name:'Abhi',city:'Lalitpur'},
                    {name:'shree',city:'Kathmandu'},
                    {name:'rameshwor',city:'Bhojpur'}
                   ];
            }*/
        </script>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

ngRoute should be in quotes:

var demoApp=angular.module('mainApp',['ngRoute']);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...