0
我已經在我的app.js文件 - 「requestDashboard」和「newRequestDashboard」中聲明瞭twp應用模塊...「newRequestDashboard」依賴於「requestDashboard」(我有一個對象數組,這兩個應用程序有不同的控制器分配給他們和陣列存儲在「requestDashboard」我可能試圖過度複雜這一點,但我不能因爲某種原因顯示任何對象。代碼如下:AngularJS模塊應用依賴
app.js:
angular.module('requestDashboard', ['ngRoute', 'ui.bootstrap']);
angular.module('newRequestDashboard', ['ngRoute', 'ui.bootstrap', 'requestDashboard']);
控制器在 「requestDashboard」
angular.module("requestDashboard")
.controller('requestDashboardCtrl', function ($scope) {
//Dummy Data for user requests
$scope.requests = [
{
type: "meeting1",
meetingName: "Radiology San Diego",
location:"Sheraton Ballroom 5S",
subitems: [
{
name: "ESCALATED",
desc: "Power strips at every table",
priority:"1",
planner:"Jessica Q. Planner",
time:"02/15/15 at 8:15 AM",
quantity:"3; one power strip at ever table"
},
{
name: "OPEN",
desc: "Extra table for 3",
priority:"3",
planner:"Jessica Q. Planner"
},
{
name: "ACKNOWLEDGED",
desc: "Projector for meeting",
priority:"2",
planner:"Jessica Q. Planner"
},
{
name: "CLOSED",
desc: "book exta room for 2 guests",
priority:"5",
planner:"Jessica Q. Planner"
},
{
name: "CANCELLED",
desc: "extra chairs",
priority:"1",
planner:"Jessica Q. Planner"
}
]
},
{
type: "meeting2",
meetingName: "California Almond Growers",
location:"Sheraton FL14",
subitems: [
{
name: "ESCALATED",
desc: "need some more almonds",
priority:"1",
planner:"Jessica Q. Planner"
},
{
name: "OPEN",
desc: "extra pamphlets",
priority:"4",
planner:"Jessica Q. Planner"
},
{
name: "ACKNOWLEDGED",
desc: "Power supply",
priority:"2",
planner:"Jessica Q. Planner"
}
]
},
{
type: "meeting3",
meetingName: "Association of Amateur Archaeologists",
location:"Ansley 1- FL14",
subitems: [
{
name: "ESCALATED",
desc: "need some more experience",
priority:"1",
planner:"Jessica Q. Planner"
},
{
name: "OPEN",
desc: "need dinosaurs",
priority:"3",
planner:"Jessica Q. Planner"
}
]
}
];
});
上的服務+1好點...但對於服務,該陣列將在兩個不同的控制器,在兩個不同的模塊一起使用。如果是這種情況,我將如何設置該服務?另外,您的答案中的「requestDashboard」被注入了兩次? – 2014-10-22 12:41:34