Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
下拉错误AngularJs “严格使用”; var app=angular.module('brandPortalApp'); app.directive('dropdownMultiselect',function()){ 返回{ 限制:'E', 范围:_Angularjs - Fatal编程技术网

下拉错误AngularJs “严格使用”; var app=angular.module('brandPortalApp'); app.directive('dropdownMultiselect',function()){ 返回{ 限制:'E', 范围:

下拉错误AngularJs “严格使用”; var app=angular.module('brandPortalApp'); app.directive('dropdownMultiselect',function()){ 返回{ 限制:'E', 范围:,angularjs,Angularjs,下拉错误AngularJs “严格使用”; var app=angular.module('brandPortalApp'); app.directive('dropdownMultiselect',function()){ 返回{ 限制:'E', 范围:{ 型号:'=', 选项:“=”, 预选:'=预选' }, 模板:“”+ “选择”+ ""+ “”+ “全部检查”+ “取消选中所有”“+ “”+ “{{option.value}”+ “”+ "" , 链接:功能(范围){ scope.ope

下拉错误AngularJs
“严格使用”;
var app=angular.module('brandPortalApp');
app.directive('dropdownMultiselect',function()){
返回{
限制:'E',
范围:{
型号:'=',
选项:“=”,
预选:'=预选'
},
模板:“”+
“选择”+
""+
“”+
"" ,
链接:功能(范围){
scope.openDropdown=函数(){
scope.selected_items=[];

对于(var i=0;i)请给出一个复制错误的完整示例,并发布准确完整的错误消息。您是否将预先选择的
传递给您的指令?例如
@JBNizet error msg看起来像TypeError:无法读取fn处m.scope.openDropdown(AddPricePromotionCtrl.js:27)中未定义的属性“length”编译时求值(angular.js:14539),:4:520)在b(angular.js:15628)在e(angular.js:25172)在m.$eval(angular.js:17378)在m.$apply(angular.js:17478)在HTMLButtonElement.(angular.js:25177)在HTMLButtonElement.dispatch(jquery.min.js:3)在HTMLButtonElement.q.handle(jquery.min.js:3)这应该是一个问题,以及再现错误的完整最小示例。
'use strict';

var app = angular.module('brandPortalApp');

app.directive('dropdownMultiselect', function(){
    return {
        restrict: 'E',
        scope:{           
            model: '=',
            options: '=',
            pre_selected: '=preSelected'
        },
        template: "<div class='btn-group' data-ng-class='{open: open}'>"+
        "<button class='btn btn-small'>Select</button>"+
        "<button class='btn btn-small dropdown-toggle' data-ng-click='open=!open;openDropdown()'><span class='caret'></span></button>"+
        "<ul class='dropdown-menu' aria-labelledby='dropdownMenu'>" + 
        "<li><a data-ng-click='selectAll();'> Check All<i class='glyphicon glyphicon-ok'></i> </a></li>" +
        "<li><a data-ng-click='deselectAll();'> Uncheck All<i class='glyphicon glyphicon-remove'></i> </a></li>" +                    
        "<li class='divider'></li>" +
        "<li data-ng-repeat='option in options'> <a data-ng-click='setSelectedItem()'>{{option.value}}<span data-ng-class='isChecked(option.value)'></span></a></li>" +                                        
        "</ul>" +
        "</div>" ,
        link: function(scope){

            scope.openDropdown = function(){        
                scope.selected_items = [];
                for(var i=0; i<scope.pre_selected.length; i++){                        
                    scope.selected_items.push(scope.pre_selected[i].value);
                }      

            };

            scope.selectAll = function () {
                scope.model = _.pluck(scope.options, 'value');
            };            
            scope.deselectAll = function() {
                scope.model=[];
            };
            scope.close = function() {
                scope.dropdown=false; 
            };
            scope.setSelectedItem = function(){
                var id = this.option.value;
                if (_.contains(scope.model, value)) {
                    scope.model = _.without(scope.model, value);
                } else {
                    scope.model.push(value);
                }
                return false;
            };
            scope.isChecked = function (value) {                 
                if (_.contains(scope.model, value)) {
                    return 'glyphicon glyphicon-ok';
                }
                return false;
            };                                 
        }
    } 
});