我在玩这个 plnkr:http ://plnkr.co/edit/DRJtivCrxQy4s22ntsci
控制器是:
angular.module('starter.controllers', [])
.controller('AppCtrl', function($scope) {})
.controller('DisplayCtrl', function($scope, ModalFactory) {
$scope.array = null; //initialize to null
$scope.run = function() {
var array = [{ //arbitrary array of UNKNOWN fields
"a": 0,
"b": 1
}, {
"a": 1,
"b": 8
}, {
"a": 2,
"b": 5
}, {
"a": 3,
"b": 7
}, {
"a": 4,
"b": 0
}, {
"a": 5,
"b": 3
}, {
"a": 6,
"b": 6
}, {
"a": 7,
"b": 4
}, {
"a": 8,
"b": 2
}, {
"a": 9,
"b": 9
}];
$scope.array = array;
ModalFactory.init($scope).then(function(modal) {
modal.show();
});
}
});
模态是通过工厂创建的:
angular.module('modalfactory',['ionic'])
.service('ModalFactory', function($ionicModal, $rootScope) {
var init = function($scope) {
var promise;
$scope = $scope;
promise = $ionicModal.fromTemplateUrl('array.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.modal = modal;
return modal;
});
$scope.openModal = function() {
$scope.modal.show();
};
$scope.closeModal = function() {
$scope.modal.hide();
};
$scope.$on('$destroy', function() {
$scope.modal.remove();
});
return promise;
}
return {
init: init
}
})
如果单击“显示”,则会弹出一个模式窗口。我希望能够在其中显示任意数组。ng-grid 不能按我想要的方式工作。我们怎样才能做到这一点?