将promise参数传递给嵌套指令

时间:2015-08-27 12:48:04

标签: angularjs angularjs-directive

不幸的是,代码是在Typescript中,但希望有人能够指出我正确的方向。我们希望将tags-input指令嵌入到指令中。它接受过滤数据的承诺。我想将控件嵌入另一个指令并从那里传递promise。我所做的工作但参数未通过。这有点难以解释所以我将展示代码的缩减版本。干杯,克里斯。

这是父指令

<sn-location-selector auto-complete="Model.Populate($query)" browselist="Model.Cache.CachedLocations" ng-model="Model.SelectedLocations2"></sn-location-selector>

Model.Populate有一个$ query参数,该参数不会从自动完成中“传回”到页面。

        control.directive("snLocationSelector", ["Cache", "$rootScope", "$timeout",(Cache: Services.CacheService, Root: ng.IRootScopeService, $timeout: ng.ITimeoutService): any =>
        {
            return {
                restrict: "EA",
                templateUrl: "/control/snlocationselector.html",
                require: "ngModel",
                scope: {
                    disabled: "=?ngDisabled",
                    ngModel: "=",
                    autoComplete: '&',
                    browselist: "="
                },
                //replace: true,
                link:
                {
                    pre: (scope, element, attributes, controller: ng.INgModelController): void =>
                    {
                        scope.innerAutoComplete = scope.autoComplete;

                    },
                    post: (scope, element, attributes, controller: ng.INgModelController): void =>
                    {

                    }                                                
                }
            }
        }]);

这是内部指令

的控件
<tags-input class="dashboard-tags" ng-model="ngModel"
            id="{{id}}"
            name="{{controller.$name}}"
            display-property="Name"
            add-from-autocomplete-only="true"
            on-tag-added="BrowseAddTag($tag)"
            on-tag-removed="BrowseRemoveTag($tag)"
            placeholder="Start typing a location or division...">
    <auto-complete source="inner-auto-complete($query)" min-length="1" load-on-focus="true" highlight-matched-text="false"></auto-complete>
</tags-input>

1 个答案:

答案 0 :(得分:1)

范围函数名称不得转换为虚线形式。尝试使用public class PrimaryFrame extends JFrame{ //private JTextField textField1; JPanel gui; JLabel imageCanvas; public PrimaryFrame() { super( "Pathology-1" ); //setLayout(new FlowLayout()); //textField1 = new JTextField("Chup!", 50); //add(textField1); } public void setImage(Image image) { imageCanvas.setIcon(new ImageIcon(image)); } public void initComponents() { if (gui==null) { gui = new JPanel(new BorderLayout()); gui.setBorder(new EmptyBorder(5,5,5,5)); imageCanvas = new JLabel(); JPanel imageCenter = new JPanel(new GridBagLayout()); imageCenter.add(imageCanvas); JScrollPane imageScroll = new JScrollPane(imageCenter); imageScroll.setPreferredSize(new Dimension(300,100)); gui.add(imageScroll, BorderLayout.CENTER); } } public Container getGui() { initComponents(); return gui; } } 代替innerAutoComplete

inner-auto-complete