2

我在应用程序中同时使用 ng-tag-input 和 ui-block。我正在使用自动完成 ng-tag-input。当我在输入标签中输入 3 个字母时,它不显示建议的标签。

它给出了错误:

Error: [$rootScope:inprog] $digest already in progress
http://errors.angularjs.org/1.2.22/$rootScope/inprog?p0=NaNigest
    at VALIDITY_STATE_PROPERTY (http://localhost:9000/bower_components/angular/angular.js:78:12)
    at beginPhase (http://localhost:9000/bower_components/angular/angular.js:12966:15)
    at Scope.$get.Scope.$apply (http://localhost:9000/bower_components/angular/angular.js:12755:11)
    at HTMLInputElement.<anonymous> (http://localhost:9000/bower_components/ng-tags-input/ng-tags-input.min.js:1:4856)
    at HTMLInputElement.jQuery.event.dispatch (http://localhost:9000/bower_components/jquery/dist/jquery.js:4641:9)
    at HTMLInputElement.jQuery.event.add.elemData.handle (http://localhost:9000/bower_components/jquery/dist/jquery.js:4309:46)
    at BlockUI.blkUI.factory.reset (http://localhost:9000/bower_components/angular-block-ui/dist/angular-block-ui.js:329:28)
    at BlockUI.blkUI.factory.stop (http://localhost:9000/bower_components/angular-block-ui/dist/angular-block-ui.js:301:14)
    at Object.blkUI.factory.utils.forEachFn (http://localhost:9000/bower_components/angular-block-ui/dist/angular-block-ui.js:453:19)
    at Array.blkUI.factory.utils.forEachFnHook.arr.(anonymous function) [as stop] (http://localhost:9000/bower_components/angular-block-ui/dist/angular-block-ui.js:458:15) 

但是当我从中删除 ui-block 时app.ng-tag-input工作正常。

控制器 :

var app = angular.module('plunker', ['ngTagsInput','blockUI']);

app.controller('MainCtrl', function($scope, $http) {
  $scope.tags = [
    { text: 'Tag1' },
    { text: 'Tag2' },
    { text: 'Tag3' }
  ];

  $scope.loadTags = function(query) {
    return $http.get('tags.json');
  };
});

html:

<body ng-controller="MainCtrl">
    <tags-input ng-model="tags">
      <auto-complete source="loadTags($query)"></auto-complete>
    </tags-input>
    <p>Model: {{tags}}</p>
  </body>

我认为 ui-block 与 ng-tag-input 不兼容。请建议我如何克服这个问题?见 plunker

4

2 回答 2

1

在 angular-block-ui.js 第 594 行注入 $timeout 然后在 t[fnName].apply(t, args) 中使用它,如下所示:

blkUI.factory('blockUIUtils', function($timeout) {

      var $ = angular.element;

      var utils = {
        buildRegExp: function(pattern) {
          var match = pattern.match(/^\/(.*)\/([gim]*)$/), regExp;

          if(match) {
            regExp = new RegExp(match[1], match[2]);
          } else {
            throw Error('Incorrect regular expression format: ' + pattern);
          }

          return regExp;
        },
        forEachFn: function(arr, fnName, args) {
          var i = arr.length;
          while(i--) {
            var t = arr[i];
            $timeout(function(){
              t[fnName].apply(t, args);
            });

          }
        }
于 2015-07-15T08:50:53.373 回答
0

试试这个(来自http://angular-block-ui.nullest.com/#!/examples/documentation):

angular.module('myApp').config(function(blockUIConfig) {

 blockUIConfig.autoBlock = false;

});
于 2016-04-18T15:13:11.970 回答