javascript - Angular compile new dom with directive -
i have angular app in there process add new dom elements. example:
$("#thingsappendedhere").append(' <div id="imnewlyappended"> <directive something="someobject" /> </div> ');
which produce:
<div id="thingsappendedhere> <div id="imnewlyappended"> <directive something="someobject" /> </div> </div>
and directive:
someapp.directive('directive', function() { return { restrict: 'e', templateurl: 'directive.html', controller: directivecontroller, scope: { something: '=' } }
and compilation is:
var scope = angular.element('#thingsappendedhere').scope(); var element = angular.element('#imnewlyappended'); $injector.invoke(function($compile) { $compile(element)(scope); });
the problem after manual compile directive doesnt have $scope.something. seems it's scope #thingsappendhere div. assume because forced scope while doing compile.
what can make work? how can tell directive creates own isolated scope , bind '$scope.something' outer scope '$scope.someobject'
kind regards.
Comments
Post a Comment