在指令中使用selected [英] Using selected in a directive

查看:77
本文介绍了在指令中使用selected的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的追踪者可以在我的控制器中完美运行.但是,当将其添加到指令中时,它会起作用,而且我希望它是在指令中选择的剂量器.

I have following that works perfectly in my controller. But when adding it to a directive it dosent work, and I expect it to be that selected dosent work in directives.

directive("multiSelectList", function () {
    return {
        scope: {
            datasource: "=",
            datasourceSelected: "="
        },
        template: 
        "<div class='col-md-12'> \
            <div class='button-group'> \
                <button type='button' class='btn btn-default btn-block btn-sm dropdown-toggle' data-toggle='dropdown'><span class=''>TurbineNumber</span> <span class='caret'></span></button> \
                <ul class='dropdown-menu' style=''> \
                    <li style='padding-left:10px;' ng-repeat='c in datasource'> \
                        <label style='font-weight:100;'> \
                            <input type='checkbox' ng-model='selected[$index]' ng-change='selected[$index] ? datasourceSelected.push(c.Name): datasourceSelected.splice(datasourceSelected.indexOf(c.Name), 1)' />&nbsp;{{c.Name}} \
                        </label> \
                    </li> \
                </ul> \
            </div> \
        </div>"
    };
});

推荐答案

问题必须出在指令的声明中,请使用下面的HTML.

the issue must be in the declaration of the directive, please use the below HTML.

<multi-select-list datasource="turbineNumbersDistinct" datasource-selected="output">
</multi-select-list>

JSFiddle演示

这篇关于在指令中使用selected的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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