mercredi 1 mars 2017

Can't set a crud route path in angularjs

I'm trying to set a router for basic posts CRUD actions using ngRouter

Router work with 1 parameter path e.g. .when ('/home') , .when('/posts)

But on .when('/post/create') or .when('/post/:action') it causes an infinite loop in console with following error: "WARNING: Tried to load angular more than once" causes page to crash

Knowing this is Laravel/Angular project where laravel routes set to load bootstrap page and angualr handel all route.

here is my config code

myApp.config(['$routeProvider','$locationProvider',
    function($routeProvider, $locationProvider){

        $locationProvider.html5Mode({
               enabled: true,
               requireBase: false
        });

        $routeProvider
            .when('/',{
                templateUrl:'templates/home.html',
                controller: 'mainCtrl'
            })
            .when('/login',{
                templateUrl:'templates/login.html',
                controller:'authCtrl'
            })      
            .when('/posts',{
                template:'posts',
                controller: 'mainCtrl'
            })          
            .when('/post/create',{
                templateUrl:'templates/post/create.html',
                controller:'mainCtrl'
            })
            ;

        $routeProvider.otherwise('/');
    }
]);

enter image description here

any idea why is this happening ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire