在我的主頁中有兩個鏈接。點擊其中應顯示一些預定義數據的表格。下面是主要的代碼頁面級如何在角度js中跨頁面傳遞數據
adminHomeContent.jsp
<body>
<div id="page-wrapper" >
<div id="page-inner">
<a href="getfeedbackList">Get List Normal</a>
<div class="row text-center pad-top">
<a ng-click="setRoute('feedbacklist')">Get List Angular JS</a>
</div>
</div>
</div>
</body>
問題是,如果我我就Get List Normal
點擊。它正確顯示結果,但在不同的頁面上不會進行局部頁面更新(儘管可以使用iframe
來完成)。如果我點擊Get List Angular
它會進入頁面,但我無法將任何數據發送到新頁面。
對於Get List Normal
我們在控權
的HelloController映射的URL的.java
public class HelloController {
@Autowired
FeedbackServices feedbackServices;
@RequestMapping(value = "/", method = RequestMethod.GET)
public ModelAndView getData() {
System.out.println("Home Controller");
ModelAndView model = new ModelAndView("adminHome");
return model;
}
@RequestMapping(value = "getfeedbackList", method = RequestMethod.GET)
public ModelAndView getfeedbackList(ModelAndView model) throws IOException {
System.out.println("getfeedbackList Controller");
List<FeedbackBean> listFeedback = feedbackServices.getFeedbacklist();
return new ModelAndView("feedbacklist", "listFeedback", listFeedback);
}
}
及其在角JS頁面導航正在由這個 -
successLadder完成.js
angular.module('successladder', [])
.config(function ($routeProvider)
{
$routeProvider
.when('/feedbacklist', {template: 'partial/pages/feedbacklist.jsp'})
.otherwise({redirectTo: '/adminHomeContent', template: 'partial/pages/adminHomeContent.jsp'});
});
function MainCtrl($scope, $location)
{
$scope.setRoute = function (route)
{
$location.path(route);
};
$scope.showModal = false;
$scope.toggleModal = function() {
$scope.showModal = !$scope.showModal;
};
}
我可以用iframe
來實現,但我想用angualr js來實現。任何想法如何在angualr js中實現這一個?
您可以使用$ rootscope或創建服務 – brk