2015-02-19 3 views
-3

Я пишу базовый код угловой маршрутизации, в котором, если пользователь нажимает на подробные сведения, будет отображаться соответствующий идентификатор заказа. Я получаю сообщение об ошибке. Где я ошибаюсь? Я добавил образец файла HTML.Проблема с маршрутизацией в angularjs

<html ng-app="sample"> 
<head> 
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular.min.js"></script> 
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> 
</head> 
<body ng-controller="test"> 
    <div class="container"> 
     <table class="table"> 
      <thead> 
       <tr> 
        <th>#</th> 
        <th>Order</th> 
        <th>Details</th>  
        <th></th> 
       </tr> 
      </thead> 
      <tbody> 
       <tr ng-repeat="order in orders"> 
        <td>{{order.id}}</td> 
        <td>{{order.number}}</td> 
        <td>{{order.details}}</td> 
        <td><a href="#ShowOrder/{{order.number}}">show details</a></td> 
       </tr> 
      </tbody> 
     </table> 
    </div> 
</body> 
<script> 
    var sample=angular.module("sample",[]); 
    sample.controller("test",function($scope){ 
     var person1={id:"1",number:"1234",details:"samsung mobile"}; 
     var person2={id:"2",number:"1235",details:"motorola mobile"}; 
     var person3={id:"1",number:"1236",details:"MI3 mobile"}; 
     var person=[person1,person2,person3]; 
     $scope.orders=person; 
    });  
    sample.config(function($routeProvider){ 
     $routeProvider.when("/ShowOrder/:id", 
      {controller:"showOrderCtrl",templateUrl:"template/order.html"});  
    }) 
    sample.controller("showOrderCtrl",function($scope,$routeParams){ 
     $scope.order_id=$routeParams.id; 
    })  
</script> 

+0

Вы, кажется, не хватает ' angular-route.js' и "ngRoute" для стартеров. Теги '

Смежные вопросы