Javascript 表达式';未定义';在属性中';材料开关&x27;与指令'一起使用;{2} &x27;是不可转让的!(角度)

Javascript 表达式';未定义';在属性中';材料开关&x27;与指令'一起使用;{2} &x27;是不可转让的!(角度),javascript,angularjs,angular-material,Javascript,Angularjs,Angular Material,我在Angular 1.3中使用Angular材质,并实现了一个材质切换按钮,该按钮基本上具有“开/关”外观,我将使用该按钮返回真/假布尔值 单击下面的div时,返回以下错误: Expression 'undefined' in attribute 'materialSwitch' used with directive '{2}' is non-assignable! //我的模板 <div class="user-material-switch" material-switch=""

我在Angular 1.3中使用Angular材质,并实现了一个材质切换按钮,该按钮基本上具有“开/关”外观,我将使用该按钮返回真/假布尔值

单击下面的div时,返回以下错误:

Expression 'undefined' in attribute 'materialSwitch' used with directive '{2}' is non-assignable!
//我的模板

<div class="user-material-switch" material-switch=""></div>

//我的指令

abcdDirectives.directive('materialSwitch', function() {
return {
    restrict: 'A',
    scope: {
        'model': '=',
        'switchDisabled' : '=',
        'switchLabel': '@'
    },
    template: '<div class="material-switch" ng-click="switch()" ng-class="{active: model, disabled: switchDisabled}"><div class="switch-back"></div><div class="switch-front"></div></div>',
    link : function(scope, element, attrs) { 
        scope.switch = function() {
            if (scope.switchDisabled) {
                return;
            }
            scope.model = !!!scope.model;
        }
    }
 }
});
指令('materialSwitch',function(){ 返回{ 限制:“A”, 范围:{ “模型”:“=”, “开关禁用”:“=”, “switchLabel”:“@” }, 模板:“”, 链接:函数(作用域、元素、属性){ scope.switch=函数(){ if(范围开关禁用){ 返回; } scope.model=!!!scope.model; } } } });
知道我做错了什么吗?

修复了-在材质切换后我没有附加模型的模板上=“”