0
我有2個控制器。如何避免在angularjs冗餘變量
第一個是listController.js:
app.controller('listCtrl', function($scope, $http, $controller, $window) {
$scope.user = [{id:1,name:'rina'},{id:2,name:'anna'},{id:3,name:'yuna'}];
});
,第二個是editController.js
app.controller('editCtrl', function($scope, $http, $controller, $window) {
$scope.user = [{id:1,name:'rina'},{id:2,name:'anna'},{id:3,name:'yuna'}];
});
正如u能看到。我在兩個控制器中都使用了變量$scope.user
。現在我想用它一次。我的意思是我想避免冗餘代碼。我如何在我的任何控制器中調用該變量。有什麼建議麼?