TypeError:i.match不是一个函数 [英] TypeError: i.match is not a function

查看:498
本文介绍了TypeError:i.match不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



控制器内的代码:

  $ scope.alertOnEventClick = function(event,allDay,jsEvent,view){
$ scope.alertMessage =(event.title +'被点击)
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'>我是一个模态!< / h3>+
< / div>< div class = '模态体' >< UL><李> jfksdfhjksd< /立GT;<李> jfksdfhjksd< /立GT;<李> jfksdfhjksd< /立GT;< / UL>< / DIV>中+
< div class ='modal-footer'>< button class ='btn btn-primary'> OK< / button>+
< button class ='btn btn-warning'>取消< / button>< / div>,
控制器:ModalInstanceCtrl,
范围:$ scope
});



函数ModalInstanceCtrl($ scope,$ modalInstance){
console.log(controller class called)
};

我仍然面临着引导ui弹出模式的问题。

解决方案


我以前也面临过这个问题。进一步的调查,我可以
了解,根据角度指南,孤立的范围只能
具有自定义指令的属性。如果我们尝试创建一个与任何属性不匹配的新的范围值,它会抛出错误。




 code> 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:必须以@& =
'attrName7':'= name?',// ERROR:?必须在模式
之后直接出现
...
}
});


I have been working on a drupal angularjs module. I have installed bootstrap ui, which is working fine. But when I use modal box it does not work.

The code inside the controller:

    $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")
     };

I am still facing issues with bootstrap ui popup model.

解决方案

I too faced this problem earlier. With further investigation I could understand that as per angular guidelines, the isolated scope can only have the attributes of the custom directives. It throws error if we try to create a new scope value which doesn't matches with any of the attribute.

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
    }
    ...
  }
});

这篇关于TypeError:i.match不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆