i have some app build with jQuery, and now I want to use angularjs to do some magic with my app.
What's doing my current app? 1st. - It creates some DOM elements using jquery :
<html>
<body>
<div id="wrapper"></div>
<script>
for(var i = 0; i < 20; i++) {
var $elem = $('<div>')
.attr('id', 'box-' + i)
.appendTo('#wrapper');
}
</script>
</body>
</html>
Then, i make some AJAX call, and basing on the returned JSON i know, that i want to create some new DOM element ( By jquery and handlebars ), and append it to $("#elem-2");
$.get('something', function(response){
var elemInstance = new MyElement(response); //function MyElement handles my object creation based on the response.
var $elem = elemInstance.render(); //return new jQuery Object, like: return $("<div>");
$elem.appendTo('#wrapper #box-2');
});
This works great, but because this dynamically created $elem and its "contoller" ( MyElement ) are very complex and needs to rerended often i would love to use angular to controll all element created this way.
So, the question is: Can I have something like class in OOP in angular and create new object basing on this class? Can I create angular controller in runtime? Or maybe ma approch is totaly wrong?