Angular js:使用另一个指令的指令(链接)

时间:2013-11-11 11:47:17

标签: javascript jquery angularjs twitter-bootstrap angular-ui

我正在尝试在angularjs(指令链接?)中的另一个指令中编译一个指令,显然我无法想出一个正确的方法来执行此操作。

我正在尝试编写的指令是angularui-bootstrap typeahead的扩展。目标是能够通过预先选择多个元素。

到目前为止我所得到的是以下代码:

tagSelector.js:

angular.module('xxxTagSelector', [])
    .directive('xxxTagSelector',
            function() {
                return {
                    restrict: 'E',
                    templateUrl: 'tagSelector.html',
                    scope: {
                        selectExpr: '@',
                        editable: '@',
                        onSelect: '@'
                    }
                    }
                };
            });

tagSelector.html:

<div>
    <input type="text" autocomplete="off" ng-model="selected"
           typeahead="{{selectExpr}}" 
           typeahead-editable="{{editable}}" typeahead-on-select="{{onSelect}}" 
           placeholder="Tag Search">
</div>
<div>
    <ul>
        <!-- It will display selected elements -->
    </ul>
</div>

main.html中

<xxx-tag-selector select-expr="tag as tag.label for tag in tags | filter:{label: $viewValue} | limitTo:8"
                                  id="tags" editable="true" on-select="onSelect($item, $model, $label)" >
</xxx-tag-selector>

我要做的是使用select-expr,editable和on-select参数,并在tagSelector中使用它们,而不进行任何处理。不幸的是,像字符串一样读它们似乎不是正确的道路。

你有什么想法吗?

你能指点我一些关于这个问题的好文件吗?到目前为止,我最了解的事情就是阅读suorce代码。

谢谢

0 个答案:

没有答案
相关问题