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

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

问题描述

我已经工作一个Drupal angularjs模块。我已经安装了引导用户界面,这是工作的罚款。但是当我使用模式对话框这是行不通的。

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.

在控制器内的code:

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.

推荐答案

适用范围:$范围不右看看我。我刚刚经历了类似的不伦不类的角度问题工作,在那里我得到类型错误:a.match不是一个函数做

The scope: $scope doesn't look right to me. I just worked through a similar nondescript angular issue where I got "TypeError: a.match is not a function" by doing

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

仅仅改变这个在指令中定义的范围分配:

By merely changing the scope assignment in the directive definition to this:

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

一切都开始工作了。看来角度做不正当的范围分配抛出一些奇怪的错误,没有充分检查的问题。

Everything started working again. It seems that angular throws some weird errors by doing improper scope assignment and doesn't adequately check for issues.

以下是一个指令定义的有效范围选项。

The following are the valid scope options for a directive definition.

范围:真//继承父范围

scope: true //inherit parent scope

范围:假//使用父范围

scope: false //use parent scope

范围:{} //隔离

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

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