数据不绑定

时间:2013-10-19 06:25:50

标签: angularjs

我有这段代码片段,我试图将数据内容插入到要编译的指令中。该指令已编译,但数据内容未定义。如何在任何编译指令的范围内插入任何外部数据?

var data = "Hello World";
angular.injector( [ "ng" ] )
        .invoke( [ "$compile", "$rootScope", 
            function( $compile, $rootScope ){
                if( !self.scope ){
                    self.scope = $rootScope.$new( true );
                }
                if( data ){
                    self.scope.data = data;
                }
                $compile( self.parent.find( "#" + self.id )[ 0 ] )( self.scope );
            } ] );

0 个答案:

没有答案
相关问题