Dynamically creating an angular view

前端 未结 2 1915
慢半拍i
慢半拍i 2020-12-13 00:56

I\'m making an in game UI using awesomium, at some points the game loads up and executes a chunk of javascript which is meant to create arbitrary new UI elements. e.g.

2条回答
  •  天命终不由人
    2020-12-13 01:33

    You should $compile dynamically added angular content. Something like:

    jQuery(document.body).append(
        $compile(  
            '
    {{line}}
    ' )(scope) );

    scope for any element you can get using something like:

    var scope = angular.element('#dynamicContent').scope();
    

    Also you should get $compile that can be injected in other controller.

    See also: AngularJS + JQuery : How to get dynamic content working in angularjs

提交回复
热议问题