$ compile:nonassign属性'isDisabled'中的表达式'undefined'一个属性正在工作而另一个不起作用

时间:2019-03-01 10:24:59

标签: angularjs angularjs-directive angular-components

我在下面给出了这个主要ctrl, rFileUploadrFilePreview是指令组件。我想在这些文件中传递我的scope变量uploadedisDisabled,例如在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;
});

0 个答案:

没有答案