我在下面给出了这个主要ctrl,
rFileUpload
和rFilePreview
是指令组件。我想在这些文件中传递我的scope
变量uploaded
和isDisabled
,例如在widgetFileupload.ctrl.js
下面给出的变量rFileUpload
中传递
但出现异常错误:[$ compile:nonassign]与指令'rFileUpload'一起使用的属性'isDisabled'中的表达式'undefined'是不可分配的!
而uploaded
正在工作。
需要建议。
主Ctrl:
'use strict';
define(['angular',
'controllers-module',
'vruntime',
'rFileUpload',
'rFilePreview'
], function (angular, controllers) {
controllers.controller("mainCtrl",
["$scope", "directiveBinder", "$stateParams", "$controller", "$state",
function ($scope, directiveBinder, $stateParams, $controller, $state) {
angular.extend(this, $controller('BaseCtrl', {$scope: $scope}));
$scope.uploaded = false;
$scope.isDisabled = false;
}])};
widgetFileupload.ctrl.js
define(['vruntime',
'directives-module',
'jquery.form',
'rpSpinner',
'text!directives/widget.upload.html',
],
function (vRuntime, directives, form, spinner, template) {
var $q;
var rpDealerFileUpload = vRuntime.widget.BaseDirective.extend({
restrict: 'E',
replace: false,
transclude: true,
template: template,
scope: {
result: '=',
isDisabled: '=',
uploaded: '='
},
compile: function (element, attributes) {
return {
post: function (scope, elem) {
var $form = angular.element('form', elem);
$form.on('drag dragstart dragend dragover dragenter dragleave drop', function (e) {
e.preventDefault();
e.stopPropagation();
})
.on('dragover dragenter', function () {
$form.addClass('upload-dragover');
})
.on('dragleave dragend drop', function () {
$form.removeClass('upload-dragover');
})
.on('drop', function (e) {
var elem = e.originalEvent.dataTransfer;
scope.fileNameChanged(elem);
scope.$apply(function () {
scope.errorMessage = null;
});
});
scope.$on('$destroy', function () {
$form.unbind();
});
}
}
},
controller: function ($controller, $scope,$stateParams, $state) {
$scope.uploaded = false;
$scope.isDisabled = false;
});