语法错误:令牌':'不是模态中的主表达式

时间:2016-10-07 15:59:15

标签: angularjs modal-dialog multi-select

我正在尝试打开一个模态,我收到此错误

<button ng-click="openEmailModal()" class="btn btn-primary">Test Modal</button>

我打开模式,按下按钮就像这样

$scope.emailUsers = [];
      $scope.example1data = [ {label: "David"}, {label:"Jhon"}, {label:"Danny"}];
      $scope.openEmailModal = function() {
          $modal.open({
              templateUrl: 'app/main/notifications/views/details/modal.html',
              windowClass: 'modal-danger',
              resolve: {
                  emailUsers: function() {
                      return $scope.emailUsers;
                  },
                  exampe1data: function() {
                      return $scope.exampe1data;
                  }
              }
          });
      }

这是我的js

<div class="modal-body">
    <div ng-dropdown-multiselect="" options="example1data"
        selected-model="emailUsers"></div>
</div>

这是modal.html中导致错误的html

options

我认为问题是模态无法访问selected-modelemailUsers中的那些变量,所以我在modal.open中添加了resolve成员,但是没有修复错误。如何解决此错误?

更新 我将js改为this,以便我知道我在返回变量之前初始化变量并且仍然得到错误。我还将下拉列表的数据更改为字符串数组。当我在chrome中调试时,它说exampe1data是一个空数组,而 $scope.openEmailModal = function() { $modal.open({ templateUrl: 'app/main/notifications/views/details/modal.html', windowClass: 'modal-danger', resolve: { emailUsers: function() { var emailUsers = []; return emailUsers; }, exampe1data: function() { var exampe1data = ["David", "Jhon", "Danny"]; return exampe1data; } } }); } 是一个字符串数组

open(‘datapickle’, ‘rb’) as f: 
  names, F, approximate = pickle.load(f)

2 个答案:

答案 0 :(得分:2)

我认为问题是你的一些变量从:开始返回一些东西,你可以检查一下这些函数的确切返回:

resolve: {
              emailUsers: function() {
                  return $scope.emailUsers;
              },
              exampe1data: function() {
                  return $scope.exampe1data;
              }
          }

我预测您需要将其中一些返回转换为字符串。但是,让我们看看日志。

<强>更新

因此,我发现了您尝试使用的模块的问题。 Here is the link

简短回答如何修复它:

  1. 在您的脚本中加入Lodash lib。
  2. 如果这不能解决问题,请切换到this fork,修复了此问题的人,但拉请求尚未合并。

答案 1 :(得分:0)

由于@Mikki描述的问题,我最终使用了isteven multi select,除了:fff

之外,我还必须为我的模态添加一个控制器来注入数据
resolve