我有以下内容:
angular.module('admin')
.controller('AdminContentController',
['$scope', '$resource', 'gridService', 'gridSelectService', 'localStorageService', 'utilityService',
function ($scope, $resource, gridService, gridSelectService, localStorageService, utilityService ) {
localStorageService.add('ls.adminPage', 'content');
$scope.entityType = 'Content';
gridService.gridSetup($scope);
和:
angular.module('admin')
.factory('gridService',
['$resource', '$timeout', 'gridSelectService', 'localStorageService', 'utilityService',
function ($resource, $timeout, gridSelectService, localStorageService, utilityService) {
var factory = {
gridSetup: function ($scope) {
$scope.grid = {
fetching: false,
pristine: true,
pageType: 'Edit'
}
我正在初始化服务中的范围变量,但我不确定这是否是正确的方法。
有没有更好的方法让我在另一个地方为模块设置 $scope 变量?