Saturday, March 16, 2013

AngularJs compiling dynamically added dom

Scenario
We have an application where we use angular for a particular tab. So we needed to compile the ajax document.

var $injector = angular.injector(['ng', 'custom_directives']);
var controllerDiv = $j(wrapper.find('div[ng-controller]')[0]);
$injector.invoke(function($rootScope, $compile, $document){
$compile(controllerDiv)($rootScope);
$rootScope.$digest();
});
view raw gistfile1.js hosted with ❤ by GitHub