TypeError:i.match不是函数

MSK*_*MSK 3 drupal-7 angularjs angular-ui-bootstrap

我一直在研究drupal angularjs模块.我已经安装了bootstrap ui,工作正常.但是,当我使用模态框时,它不起作用.

控制器内的代码:

    $scope.alertOnEventClick = function( event, allDay, jsEvent, view ){
    $scope.alertMessage = (event.title + ' was clicked ');
    console.log($modal);

    var modalInstance = $modal.open({
        //templateUrl: Drupal.settings.angularjsApp.basePath + '/ng_node/calender/popup',
        template: "<div class='modal-header'><h3 class='modal-title'>I'm a modal!</h3>" +
            "</div><div class='modal-body'><ul><li>jfksdfhjksd</li><li>jfksdfhjksd</li><li>jfksdfhjksd</li></ul></div>"+
            "<div class='modal-footer'><button class='btn btn-primary'>OK</button>" +
            "<button class='btn btn-warning'>Cancel</button></div>",
        controller: ModalInstanceCtrl,
        scope: $scope
    });



    function ModalInstanceCtrl($scope, $modalInstance) {
     console.log("controller class called")
     };
Run Code Online (Sandbox Code Playgroud)

我仍然面临着bootstrap ui popup模型的问题.

aja*_*mar 13

我之前也遇到过这个问题.通过进一步调查,我可以理解,根据角度指南,隔离范围只能具有自定义指令的属性.如果我们尝试创建一个与任何属性都不匹配的新范围值,则会抛出错误.

myModule.directive('directiveName', function factory() {
  return {
    ...
    scope: {
      'attrName': '@', // OK
      'attrName2': '=localName', // OK
      'attrName3': '<?localName', // OK
      'attrName4': ' = name', // OK
      'attrName5': 'name',    // ERROR: missing mode @&=
      'attrName6': 'name=',   // ERROR: must be prefixed with @&=
      'attrName7': '=name?',  // ERROR: ? must come directly after the mode
    }
    ...
  }
});
Run Code Online (Sandbox Code Playgroud)


dwb*_*rtz 7

范围:$ scope看起来不对我.我刚刚完成了一个类似的非描述角度问题,我得到了"TypeError:a.match不是函数"

    app.directive('contactAssociation', function () {
    return {
        templateUrl: 'contactAssociation.html',
        restrict: 'E',
        scope: {
            contact:"=",
            isSelected : false
        },
        controller: contactAssociationController
    };
Run Code Online (Sandbox Code Playgroud)

只需将指令定义中的范围分配更改为:

    app.directive('contactAssociation', function () {
    return {
        templateUrl: 'contactAssociation.html',
        restrict: 'E',
        scope: {
            contact:"=",
        },
        controller: contactAssociationController
    };
Run Code Online (Sandbox Code Playgroud)

一切都开始了.似乎角度通过不正确的范围分配抛出了一些奇怪的错误,并且没有充分检查问题.

以下是指令定义的有效范围选项.

scope:true //继承父范围

scope:false //使用父范围

范围:{} //隔离

  • @DaveKaye我不得不将它移动到控制器函数中以将其添加到$ scope. (2认同)