Error: No parent block-ui service instance located.

半兽人 发表于: 2019-06-11   最后更新时间: 2019-06-11 00:33:59   1,961 游览

步骤如下:

<link rel="stylesheet" href="path-to-block-ui/angular-block-ui.min.css"/>
<!-- After AngularJS -->
<script src="path-to-block-ui/angular-block-ui.min.js"><//script>

创建blockUI依赖:

angular.module('myApp', ['blockUI'])

控制器使用:

angular.module('myApp').controller('MyController', function($scope, blockUI) {
  // A function called from user interface, which performs an async operation.
  $scope.onSave = function(item) {

    // Block the user interface
    blockUI.start();

    // Perform the async operation    
    item.$save(function() {

      // Unblock the user interface
      blockUI.stop();

    });
  };
});

然后就报:

Error: No parent block-ui service instance located.
    at Object.<anonymous> (http://localhost:8093/js/angularjs/block-ui/angular-block-ui.js:164:13)
    at http://localhost:8093/user/js/angular-1.5.8.min.js:16:71
    at la (http://localhost:8093/user/js/angular-1.5.8.min.js:81:90)
    at p (http://localhost:8093/user/js/angular-1.5.8.min.js:66:341)
    at http://localhost:8093/user/js/angular-1.5.8.min.js:77:24
    at http://localhost:8093/user/js/angular-1.5.8.min.js:131:20
    at m.$eval (http://localhost:8093/user/js/angular-1.5.8.min.js:145:347)
    at m.$digest (http://localhost:8093/user/js/angular-1.5.8.min.js:142:420)
    at m.$apply (http://localhost:8093/user/js/angular-1.5.8.min.js:146:113)
    at http://localhost:8093/user/js/angular-1.5.8.min.js:20:488 <div block-ui-container="" class="block-ui-container ng-scope">
发表于 2019-06-11

var srvInstance = $element.inheritedData('block-ui');

换成

var srvInstance = $element.parent().data('block-ui');
你的答案

查看AngularJS相关的其他问题或提一个您自己的问题