I have below 2 files , index.html files makes an ajax call using angular to ajax.html, ajax.html file contains some angular code, i need the rendered angular code of ajax.html in index.html so I could replace it in div#listelement. I am not able to get the render code
index.html(code)
<!DOCTYPE html>
<html lang="en" ng-app="myAppUpdate">
<head>
<meta charset="UTF-8">
<title>Angular Ajax HTML Render</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
</head>
<body ng-controller="myControllerUpdate">
<div id="listelement">
<li>old data</li>
<li>old data v2</li>
</div>
<script>
var jq = $.noConflict();
var myAppUpdate = angular.module('myAppUpdate',[]);
console.log('outside');
// var myApp = angular.module('myApp',['ui.bootstrap']);
myAppUpdate.controller('myControllerUpdate', function ($scope,$http,$compile) {
console.log('inside');
$http.get('ajax.html')
.success(function (data) {
console.log(data);
console.log('working');
var html = jq('#listelement').html(data);
$compile(html)($scope);
// var newstuff = $formBlock.html(response);
// $compile(newstuff)(scope);
});
});
</script>
</body>
</html>
ajax.html(code)
<div data-ng-controller="myController">
<li ng-repeat="x in data">
{{x}}
</li>
</div>
<script>
var myApp = angular.module('myAppUpdate',[])
myApp.controller('myController',function ($scope) {
$scope.data = ['1','2','3'];
});
</script>
</body>
</html>