我已经在我的app.js文件中声明了twp应用模块-“requestDashboard”和“newRequestDashboard”……“newRequestDashboard”依赖于“requestDashboard”(我有一个想要显示的对象数组)。这两个应用程序都有一个不同的控制器分配给它们,数组存储在"requestDashboard“中。我可能试图使这件事过于复杂,但由于某种原因,我无法显示任何对象。代码如下:
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"
}
]
}
];
});发布于 2014-10-21 22:34:01
在您的应用程序中有许多应用程序是非常常见的。但你应该对此采取不同的方法。在解决方案中,您声明了对所有应用程序的依赖。如果您的应用程序变得更大,这将发生冲突。你应该这样做。
// 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']);关于你的问题,你为什么不使用服务?服务可以在控制器中使用,然后您可以显示回您的视图。
希望这能有所帮助
https://stackoverflow.com/questions/26496335
复制相似问题