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 %}