0
我正在嘗試創建一個應用程序(http://plnkr.co/edit/EVasje),該應用程序有兩個步驟,鏈接&基於示例http://jsfiddle.net/cfulnecky/NRUxs/的部分。AngularJS部分重新加載
現在,如果您點擊個案,我會得到一個個案列表,如果我點擊任何情況右側面板更新但只有一次。點擊其他鏈接似乎不會重新加載部分。
任何想法我做錯了什麼? [代碼樣品的一部分在這裏]
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"}}] }; });
幫助是不勝感激。
感謝
嘿,我想通了這一點了。實際上,我在郵件列表中提出了同樣的問題,但沒有人回答。我完全按照你的建議做了。謝謝無論如何,我已經接受你的答案:) – Mahbub
很好,你找到了解決方案。 :)如果你找到自己問題的答案,你應該將其作爲答案作爲進一步參考。你甚至可以接受你自己的答案! – Narretz
其實我打算(就像我在谷歌郵件列表上所做的那樣),我知道我可以回答我自己的問題,但看到你做了它,並認爲我應該接受;) – Mahbub