如果您希望某些东西可以被多个控制器使用,则应该使用服务。这是一个简单的示例:
myApp.factory('ListService', function() { var ListService = {}; var list = []; ListService.getItem = function(index) { return list[index]; } ListService.addItem = function(item) { list.push(item); } ListService.removeItem = function(item) { list.splice(list.indexOf(item), 1) } ListService.size = function() { return list.length; } return ListService;});function Ctrl1($scope, ListService) { //Can add/remove/get items from shared list}function Ctrl2($scope, ListService) { //Can add/remove/get items from shared list}

![模型数据和行为放在哪里?[tl; 博士 使用服务] 模型数据和行为放在哪里?[tl; 博士 使用服务]](http://www.mshxw.com/aiimages/31/448297.png)
