Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 角流星;铁路由器:如何使用嵌套路由?_Angularjs_Meteor_Iron Router_Angular Meteor - Fatal编程技术网

Angularjs 角流星;铁路由器:如何使用嵌套路由?

Angularjs 角流星;铁路由器:如何使用嵌套路由?,angularjs,meteor,iron-router,angular-meteor,Angularjs,Meteor,Iron Router,Angular Meteor,我有这样一个收藏:(许多国家,每个国家包含许多地区) 然后,我用铁路由器设置了一些适合“国家”的路线 app.js Countries = new Mongo.Collection('countries'); if (Meteor.isClient) { angular.module('geo',['angular-meteor', 'ui.router']); angular.module('geo').config(function($urlRouterProvider, $s

我有这样一个收藏:(许多国家,每个国家包含许多地区)

然后,我用铁路由器设置了一些适合“国家”的路线

app.js

Countries = new Mongo.Collection('countries');

if (Meteor.isClient) {

  angular.module('geo',['angular-meteor', 'ui.router']);

  angular.module('geo').config(function($urlRouterProvider, $stateProvider, $locationProvider){

    $locationProvider.html5Mode(true);

    $stateProvider
      .state('countries', {
        url: '/countries',
        templateUrl: 'countries.html',
        controller: 'countries_controller'
      })
      .state('country', {
        url: '/countries/:countryId',
        templateUrl: 'country.html',
        controller: 'country_controller'
      })
      .state('region', {
        url: '/countries/:countryId/regions/:regionId',
        templateUrl: 'region.html',
        controller: 'country_controller'
      });

    $urlRouterProvider.otherwise("/countries");
  });

  angular.module('geo').controller('countries_controller', ['$scope', '$meteor', '$state',
    function ($scope, $meteor, $state) {

      $scope.countries = $meteor.collection(function() {
          return Countries.find({})
      });

  }]);

  angular.module('geo').controller('country_controller', function($scope, $meteor, $stateParams) {
    $scope.country = $meteor.object(Countries, $stateParams.countryId);
  });

}
我可以在countries.html中显示国家列表,并使用“countries/:countryId”路径将每个国家链接到自己的country.html页面

countries.html

<ul>
  <li ng-repeat="country in countries">
    <span>{{country.name}}</span>
    <a href="/countries/{{country._id}}">View</a>
    <span>Regions:</span>
    <ul>
      <li ng-repeat="region in country.regions">
        <span>{{region.name}}</span>
        <a href="countries/{{country._id}}/regions/{{region._id}}">View</a>
      </li>
    </ul>
  </li>
</ul>

在控制台中是否有任何错误?“region.html”模板中有什么内容?@shershen我已经添加了region.html的内容
<ul>
  <li ng-repeat="country in countries">
    <span>{{country.name}}</span>
    <a href="/countries/{{country._id}}">View</a>
    <span>Regions:</span>
    <ul>
      <li ng-repeat="region in country.regions">
        <span>{{region.name}}</span>
        <a href="countries/{{country._id}}/regions/{{region._id}}">View</a>
      </li>
    </ul>
  </li>
</ul>
{{region.name}}