0

http://jsfiddle.net/cfulnecky/NRUxs/の例に基づいて、2つのステップのリンクとパーシャルを持つアプリ( http://plnkr.co/edit/EVasje )を作成しようとしています。

ここで、[ケース]をクリックすると、ケースのリストが表示されます。いずれかのケースをクリックすると、右側のパネルが更新されますが、1回だけ更新されます。他のリンクをクリックしても、パーシャルがリロードされていないようです。

私が間違っていることは何ですか?[ここのコードサンプルの一部]


var app = angular.module('plunker', []);

app.config(['$routeProvider', function($routeProvider) {    
    $routeProvider.when('/',                {template: { left : 'dashboard.html', right: ''}});
    $routeProvider.when('/cases',           {template: { left : 'cases.html', right: ''}});
    $routeProvider.when('/cases/view/:id',  {template: { left : 'cases.html', right: 'caseDetail.html'}});
    $routeProvider.when('/departments',        {template: { left : 'departments.html', right: ''}});
    $routeProvider.otherwise({redirectTo: '/'});     }]);

app.controller('AppController', ['$rootScope','$scope','$route', '$location','$controller', function ($rootScope,$scope,$route,$location,$controller) {            
    $rootScope.$on('$routeChangeStart', function(scope, newRoute, Current){                              
        if (!newRoute) return;                
        $rootScope.template = newRoute.$route.template;        
    });
    $scope.isActive = function(route) {      
        return route === $location.path();
    };      }]);    function CasesCtrl($scope,CaseFactory) {        $scope.cases = CaseFactory.getCases;   }

function CaseDetailCtrl($scope,$route) {    $scope.caseNum = $route.current.params.id; }

app.factory('CaseFactory', function() {   return {
    getCases:[{"project":{"id":3,"name":"Listings"},"updated_on":"2012-09-17T17:30:00Z","tracker":{"id":1,"name":"Bug"},"created_on":"2012-09-17T17:30:00Z","author":{"id":4,"name":"John Doe"},"id":22,"status":{"id":1,"name":"New"},"start_date":"2012-09-17","subject":"Check all the content with copy scape using APi","description":"","priority":{"id":4,"name":"Normal"}},{"project":{"id":3,"name":"Listings"},"updated_on":"2012-09-17T17:29:48Z","tracker":{"id":1,"name":"Bug"},"created_on":"2012-09-17T17:29:48Z","author":{"id":4,"name":"John Doe"},"id":21,"status":{"id":1,"name":"New"},"start_date":"2012-09-17","subject":"Scrap all the sites who have similar content","description":"","priority":{"id":4,"name":"Normal"}},{"project":{"id":6,"name":"Quran"},"updated_on":"2012-09-17T17:26:54Z","tracker":{"id":1,"name":"Bug"},"created_on":"2012-09-17T17:26:54Z","author":{"id":4,"name":"John Doe"},"id":20,"status":{"id":1,"name":"New"},"start_date":"2012-09-17","subject":"Add jQuery UI Layout to Admin Panel","description":"","priority":{"id":4,"name":"Normal"}}]     }; });

ヘルプは大歓迎です。

ありがとう

4

1 に答える 1

1

パーシャルをリロードすることにはそれほど問題はないようですが、新しいルートIDパラメーターをスコープに割り当てる必要があることをangularに伝えることには問題があるようです。ルートを監視し、それに応じてスコープを更新するようにコントローラーに指示する必要があります。これは機能します:

function CaseDetailCtrl($scope,$route, $rootScope) {
  $scope.caseNum = $route.current.params.id;  
  $rootScope.$on('$routeChangeSuccess', function(scope, newRoute, Current){                              
      $scope.caseNum = $route.current.params.id;     
  });
}

http://plnkr.co/edit/TaV3gT?p=preview

于 2012-10-21T12:05:30.807 に答える