Bonjour,
je trouve cette erreur quand il peut stocker variable en local , le probléme qui je trouve c'est au début en configuration de local storage .
je travaille avec cette tuto : https://github.com/grevory/angular-local-storage#get-started

voilà code:

{% extends 'base.html.twig' %}
    {% block title %} Acceuil {% endblock %}
    {% block stylesheets %}<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/cerulean/bootstrap.min.css">
    <style>

    a {
        text-decoration:none;
        color: #e74c3c;
            margin-right: 25px;

    }

    </style>

    {% endblock %}
    {% block body %}
    <div class="container" ng-app="myApp">
        <a href="#/!">Acceuil</a>

    <a href="#!login">Login</a>
    <a href="#!register">Register</a> <br><br>

    <div ng-view></div>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.5/angular-route.js"></script>
    <script src="angularlocalstorage.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/todc-bootstrap/3.3.7-3.3.13/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="{{ asset('bundles/fosjsrouting/js/router.js') }}"></script>
    <script type="text/javascript" src="{{ path('fos_js_routing_js', {"callback": "fos.Router.setData"}) }}"></script>
    <scritp src="app.js"></script>
    <script>
    var app = angular.module("myApp", ["ngRoute","LocalStorageModule"]);

    app.config(['$routeProvider, function($routeProvider) {
      $routeProvider
        .when("/login", {
          templateUrl: Routing.generate('login',
            {template:"default/login.html.twig"}),
            controller: 'loginctrl',
        })
        .when("/register", {
          templateUrl: Routing.generate('register',
            {template:"default/registere.html.twig"}),
          controller: 'httpgetctrl',  
        });

    }]);

    app.config(function (localStorageServiceProvider) {
      localStorageServiceProvider
        .setPrefix('app')
        .setStorageType('localStorage')
        .setNotify(true, true)
    });

        app.controller("httpgetctrl", function ($scope, $http) {

            $scope.SendData = function () {
               // use $.param jQuery function to serialize data from JSON 
                var data = $.param({
                    username: $scope.username,
                    email: $scope.email,
                    pass: $scope.password,
                    confir: $scope.confirmationpass
                });

                var config = {
                    headers : {
                        'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
                    }
                }

                $http.post("{{path('register')}}", data, config)
                .then(function (response) {
                    console.log("success");
                })
                .catch(function() {
                    console.log("error");
      })
            };

        });

        app.controller("loginctrl", function ($scope, $http,localStorageService) {

            $scope.login = function () {
               // use $.param jQuery function to serialize data from JSON 
                var data = $.param({
                    username: $scope.user,
                    password: $scope.pass
                });

                var config = {
                    headers : {
                        'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
                    }
                }

                $http.post("{{path('login')}}", data, config)
                .then(function (response) {
                    console.log("success");
                })
                .catch(function() {
                    console.log("error");
      })
            };

        });
    </script>

    </div>
    {% endblock %}

et voilà erreur :
https://docs.angularjs.org/error/$injector/modulerr?p0=myApp&p1=Error:%20%5B$injector:nomod%5D%20http:%2F%2Ferrors.angularjs.org%2F1.6.5%2F$injector%2Fnomod%3Fp0%3DmyApp%0A%20%20%20%20at%20https:%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.6.5%2Fangular.min.js:7:76%0A%20%20%20%20at%20https:%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.6.5%2Fangular.min.js:26:408%0A%20%20%20%20at%20b%20(https:%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.6.5%2Fangular.min.js:25:439)%0A%20%20%20%20at%20https:%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.6.5%2Fangular.min.js:26:182%0A%20%20%20%20at%20https:%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.6.5%2Fangular.min.js:42:290%0A%20%20%20%20at%20p%20(https:%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.6.5%2Fangular.min.js:8:7)%0A%20%20%20%20at%20g%20(https:%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.6.5%2Fangular.min.js:42:138)%0A%20%20%20%20at%20gb%20(https:%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.6.5%2Fangular.min.js:46:251)%0A%20%20%20%20at%20c%20(https:%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.6.5%2Fangular.min.js:22:19)%0A%20%20%20%20at%20Uc%20(https:%2F%2Fcdnjs.cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.6.5%2Fangular.min.js:22:332

2 réponses


betaWeb
Réponse acceptée

Salut,

Il manque une quote après l'injection du module $routeProvider :

app.config(['$routeProvider, function($routeProvider) { => app.config(['$routeProvider', function($routeProvider) {

med001
Auteur

merci @betaWeb