我在app.js文件中声明了twp应用程序模块 - " requestDashboard"和" newRequestDashboard" ..." newRequestDashboard"依赖于" requestDashboard"(我有一系列我想要显示的对象。两个应用程序都分配了不同的控制器,并且数组存储在" requestDashboard& #34;。我可能试图过度复杂化,但我不能出于某种原因显示任何对象。代码如下:
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"
}
]
}
];
});
答案 0 :(得分:0)
在您的应用程序中有很多应用程序是很常见的。但你应该对此采取不同的方法。在您的解决方案中,您声明对所有应用程序的依赖性。如果您的应用程序变大,哪个会发生冲突你应该这样是这样的。
// declare your app without any dependency
(function() {
var requestDashboard= angular.module( 'requestDashboard',[]);
}());
(function() {
var newRequestDashboard= angular.module( 'newRequestDashboard',[]);
}());
// inject all your dependency here
var mainApp = angular.module( 'mainApp ', ['requestDashboard','newRequestDashboard','ngRoute', 'ui.bootstrap']);
关于您的问题,为什么不使用服务?和服务可以在控制器中使用,然后您可以显示回您的视图。
希望这有帮助