Is there a way to create a custom controller programmatically while preserving scope inheritance? I am looking to achieve something similar to this:
var controller = 'myCtrl';
var html = '<p>{{value}}</p>';
var validScope= $scope.$new({
value : 'Hello, custom controllers'
}); // Or some other method to maintain valid scope inheritance
$(document.body).append(instantiate(controller, html, validScope));
I need assistance with two things: how to instantiate a custom controller and how to do it using Angular-like techniques.
UPDATE. I attempted the following approach:
$compile('<div ng-controller="myCtrl">'+html+'</div>')(validScope);
The controller was instantiated successfully. However, the bound values were not updated.