扩展UI选择控制器(角度)

时间:2016-09-05 10:38:33

标签: javascript angularjs inheritance decorator angular-ui-select

我试图扩展ui-select(版本0.17.1)以使其在点击时刷新。这里有一个例子(https://jsfiddle.net/betonetotbo/0yfhe7pf/),我一直在用它作为起点。

我希望这在app范围内发生,所以我用我自己的ui-select-choices指令替换了html,其中包含一个div按钮。我还添加了一个装饰器来替换指令控制器和一个尚未定义的新控制器。

myapp.app.config(function(provide) {
    $provide.decorator("uiSelectDirective", [ "$delegate", "uiSelectConfig", "$controller"], function ($delegate, uiSelectConfig, $controller) {
        var directive = $delegate[0];
        // This line throws error Unknown provider
        var $select = $controller('uiSelectCtrl');

        return $delegate;
    }]);
});

我的问题是我还想装饰/扩展控制器以在整个应用程序中添加额外的功能。我不想完全重写它,所以我正在寻找扩展控制器的正确方法。

感谢。

1 个答案:

答案 0 :(得分:1)

我通过重载指令的编译方法解决了这个问题:

#include <iostream>

using namespace std;
int main()
{
    int bottom,top;
    int x;
    int pl = 0;

    cout << "Enter the bottom of the interval:";
    cin >> bottom;
    cout << "Enter the top of the interval:";
    cin >> top;

    for( x = bottom+1; x < top; x ++)
    {
        if (x % 2 == 0 & x % 4 != 0)


    }


    return 0;
}
相关问题