我正在尝试创建一个应用程序(http://plnkr.co/edit/EVasje ),它基于示例http://jsfiddle.net/cfulnecky/NRUxs/具有两步链接和部分内容。
现在,如果您单击“案例”,我会得到一个案例列表,如果我单击任何案例,则右侧面板仅更新一次。单击其他链接似乎不会重新加载部分。
知道我在做什么错吗?[这里是代码示例的一部分]
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"}}] }; });
非常感谢您的帮助。
谢谢