我有一个名为crop
$scope.crop = function (id) {
var options = {
template: "templates/polaroids_edit_crop.html",
url: PolaroidsService.getPolaroid(id).polaroid,
width: 300,
height: 300
};
$jrCrop.crop(options).then(function (canvas) {
PolaroidsService.setCropped(id, canvas.toDataURL());
});
};
但是当我调用这个函数时,我在这一行得到一个错误:
$jrCrop.crop(options).then(function (canvas)
包含:
TypeError: Cannot read property 'then' of undefined
at Scope.$scope.crop (polaroids_edit.js:51)
at $parseFunctionCall (ionic.bundle.js:21044)
at ionic.bundle.js:53458
at Scope.$eval (ionic.bundle.js:23100)
at Scope.$apply (ionic.bundle.js:23199)
at HTMLButtonElement.<anonymous> (ionic.bundle.js:53457)
at HTMLButtonElement.eventHandler (ionic.bundle.js:11713)
at triggerMouseEvent (ionic.bundle.js:2863)
at tapClick (ionic.bundle.js:2852)
at HTMLDocument.tapTouchEnd (ionic.bundle.js:2975)
$jrCrop.crop(options)
执行以下操作:
crop: function (options) {
options = this.initOptions(options);
var scope = $rootScope.$new(true);
ionic.extend(scope, options);
$ionicModal.fromTemplateUrl(template, {
scope: scope,
animation: 'slide-in-up'
}).then(function (modal) {
scope.modal = modal;
return scope.modal.show().then(function () {
return (new jrCropController(scope)).promise.promise;
});
});
}
我必须等待加载模板,只有加载模板才能返回模态。我怎么能解决这个问题?
答案 0 :(得分:3)
我认为你应该返回crop: function(options) {
options = this.initOptions(options);
var scope = $rootScope.$new(true);
ionic.extend(scope, options);
return $ionicModal.fromTemplateUrl(template, {
scope: scope,
animation: 'slide-in-up'
}).then(function(modal) {
scope.modal = modal;
return scope.modal.show().then(function() {
return (new jrCropController(scope)).promise.promise;
});
});
}
结果:
IList<T>