Angularjs 为term.js创建自定义角度指令

Angularjs 为term.js创建自定义角度指令,angularjs,angularjs-directive,terminal,Angularjs,Angularjs Directive,Terminal,我正在创建一个自定义指令供自己使用,特别是。通常使用起来非常简单: var term = new Terminal({ cols: 80, rows: 24, screenKeys: true }); term.open(document.body); term.write('\x1b[31mWelcome to term.js!\x1b[m\r\n'); 为此,我修改了hello world指令示例以满足我的需要: app.directive('terminal', fu

我正在创建一个自定义指令供自己使用,特别是。通常使用起来非常简单:

var term = new Terminal({
   cols: 80,
   rows: 24,
   screenKeys: true
});

term.open(document.body);
term.write('\x1b[31mWelcome to term.js!\x1b[m\r\n');
为此,我修改了hello world指令示例以满足我的需要:

app.directive('terminal', function() {
    return {
        restrict: 'E',
        scope: {
            name: '@'
        },
        template: '<span>Hello {{name}}<div class="term"></div></span>',
        link: function(scope, elem, attrs) {
            var term = new Terminal({
                cols: 80,
                rows: 24,
                screenKeys: true
            });
            // window.w = elem;
            term.open(elem.find("div"));
            term.write('\x1b[31mWelcome to term.js!\x1b[m\r\n');
        }
    }
});

我对AngularJS还比较陌生,不知道怎么回事。elem.find()似乎返回一个DOM对象,在JQuery中没有类似的.get()方法,但我也用JQquery(而不是jqLite)尝试过它也没关系。那么,我看不到的问题是什么?

似乎我需要做:

     term.open(elem.find("div")[0]);
TypeError: Cannot read property 'defaultView' of undefined
    at Terminal.open (http://localhost:4000/js/term.js:700:43)
    at link (http://localhost:4000/js/MyApp.js:23:18)
     term.open(elem.find("div")[0]);