Search code examples
javascriptangularjsngroute

Crash when use ngRoute angular


I wanna build SPA with angular , but I'm have this problem with it . Here is my code . In main page i'm using ng-include to navbar html:

   <div ng-include="'/project/app/client/shop/shop-header/shop-header.html'"></div>
 <div ng-view></div>

In my header page :

<li><a data-ng-href="/" class="btn btn-default" >
       <span style="color: #C62828">Shop</span>
 </a></li>
 <li >
     <a data-ng-href="/cart" class="btn btn-default" >Cart</a>
</li>

js file

 angular
            .module('app.shop',['ngRoute'])
            .config(configRoute);

            configRoute.$inject= ['$routeProvider'];

            function configRoute($routeProvider){
                $routeProvider
                    .when('/',{templateUrl:'shop.html'})
                    .when('/cart'{templateUrl:'/project/app/client/cart/cart.html'})
                    .otherwise({ redirectTo: '/' });        
                    }

but when i run main page , console log warning : try to run angular 239 times and crash. Pls help me


Solution

  • You will see that warning whenever your code has loaded more than one angular.js files, just put one and remove all the other angular.js files in your HTML , your problem will be solved