1

i'm beginner with AngularJS but i have a problem in it and i dont know how to fix it.

i will explain it to you ,

I have OneToMany relationship between a table called "Reference" and "Critere" it means that one "Reference" should contains many "criteres" so i listed all the "References" in a table.

the main problem comes to when i clik on "Reference" it should redirect me to a page called "Critere" with the id of "Reference" cliked on it, and that page "Critere" (Critere/idReference) will contains all the Criteres that are related to that "Reference". Knowing that i got all the data in Json format i'm working with Spring Boot and Rest Api , i don't have any problem in Spring cause when i try to load all the "Criteres" related to that "References" it happens but i don't know how to do it with AngularJs.

Here's My code :

<tr class="clickable-row" ng-init="chargerNoteReference(reference.idReference)" data-ng-click="redirectt(reference.idReference)">  
<td>{{reference.titleReference}}</td>
</tr>

here i load all the References listed on a table with a clickable row

i use one controller

$scope.redirectt = function(x){
     $window.location.assign("/Critere/"+x);
}

i got Also the route Params

var app = angular.module("Entourage",['ngRoute']);
app.config(function($routeProvider ){    
$routeProvider
.when('/Critere/:idReference',{
templateUrl: 'templates/Critere.html',
controller : "EntourageController",            
})       
}) 

Here is the function that i called in the Files Critere

$scope.redirect = function(){
$scope.Critere={} 
$http.get("/references/criteres/"+$scope.idReference+"/"+$scope.idUser)
.success(function(data){
$scope.Critere=data 
});
};

and here's my file Critere

<tbody ng-repeat="critere in Critere">
<tr class="odd gradeX" >
<td class="center" >{{critere.idCritere }}</td>
<td class="center">{{critere.descriptionCritere }}</td>
<td class="center"> {{critere.vue}}</td>
</tr>
</tbody>

i got also this error :

Uncaught Error: [$injector:modulerr] and i'm using thymeleaf

<script th:src="@{https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-route.js}"></script>
<script th:src="@{https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js}"></script>
 <script th:src="@{https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js}"></script>
marveshy
  • 76
  • 1
  • 8

1 Answers1

0

You shouldn't be using window.location, rather, the $location service. Ie

    $scope.redirect = function(path){
        $location.path(path); 
    }

After injecting the $location service into the controller.

JamesDill
  • 1,857
  • 1
  • 18
  • 22
  • but when i use it i got this Url : "http://localhost:8080/Domaines#/Critere/1" for me i want it to change ti "http://localhost:8080/Critere/1" i and i load all the "Criteres" belongs to the "Reference" clicked – marveshy May 21 '16 at 22:38