0

i am having trouble with the following route for the albums. below is my controller and the routes file, i am using the angular ui module. i am trying to load the photos on the album on the /photos/:albumId route.

tripApp.controller('HotelPhotoAlbumController', function($scope, $timeout, Hotel, $stateParams, $http) {

  $scope.hotelId = $stateParams.hotelId;
  $scope.albumId = $stateParams.albumId;

  $http({
    method: 'GET', url: 'hotels/' + $scope.hotelId + '/albums/' + $scope.albumId + '.json'
  }).success(function(data, status, headers, config){
    $scope.photos = data;
  }).error(function(data, status, headers, config){
    $scope.status = status;
  });

});

var tripApp = angular.module('tripApp', ['ui.state', 'ui.bootstrap', 'ui.calendar', 'ui.map', 'infinite-scroll', 'tripApp.directives', 'hotelServices', 'ngSanitize'])
    tripApp
    .value('$anchorScroll', angular.noop)
    .config(function($stateProvider, $urlRouterProvider){

      $urlRouterProvider.otherwise("/hotels")

      $stateProvider
        .state('hotels', {
            url: "/hotels",
            templateUrl: "templates/hotels.html",
            controller: "HotelsController"
        })
          .state("hotels.search", {
              url: "/search",
              templateUrl: "templates/hotels.search.html",
              controller: "HotelsController"
          })
        .state("hotel", {
          url: "/:hotelId",
          templateUrl: "templates/hotel.html",
          controller: "HotelDetailController"
        })
          .state("hotel.index", {
              url: "/",
              templateUrl: "templates/hotel.home.html",
              controller: "HotelDetailController"
          })
          .state("hotel.options", {
              url: "/options",
              templateUrl: "templates/hotel.options.html",
              controller: "HotelRoomsController"
          })
          .state("hotel.reviews", {
              url: "/reviews",
              templateUrl: "templates/hotel.reviews.html",
              controller: "HotelDetailController"
          })
          .state("hotel.photos", {
              url: "/photos",
              templateUrl: "templates/hotel.photos.html",
              controller: "HotelDetailController"
          })
          .state("hotel.photos.details", {
              url: "/photos/:albumId",
              templateUrl: "templates/hotel.photos.details.html",
              controller: "HotelPhotoAlbumController"
          })
          .state("hotel.calendar", {
              url: "/calendar",
              templateUrl: "templates/hotel.calendar.html",
              controller: "HotelCalendarController"
          })
        .state("restaurants", {
        url: "/restaurants",
        templateUrl: "templates/restaurants.html",
        controller: "RestaurantsController"
      })
    })
4

1 回答 1

1

状态 url 声明是相对于父级的,所以不是"/photos/:albumId"try "/:albumId"

于 2013-10-07T16:33:54.173 回答