Inicialice el controlador AngularJS después de agregar algunos html en DOM
¿Hay alguna manera de usar $ compilar desde javascript puro? Estoy combinando javascript básico y lugares donde estoy usando Angular y no puedo encontrar una manera de hacer algo como esto:http://jsfiddle.net/DavidSlavik/bFdcJ/1/
Creo que necesito usar $ compilar pero desde un lugar donde no haya ningún alcance.
angular.module('myApp', []);
function ExpensesCtrl($scope) {
// Here are some master functions...
}
$(function () {
// Here is the Ajax function that returns html from my MVC action processed with Razor
// Here I'm not using AngularJS and scopes...
var htmlFromAjax = '<div id="mapOrder" ng-controller="sortable"><div ng-repeat="item in SortItems">{{item.Title}}</div></div>';
$('body').append(htmlFromAjax);
});
function sortable($scope, $http, $element) {
// Here is the Ajax function that return JSON object. For example it is commented and used static variable SortItems in scope.
//$http.get('someUrlWitchReturnsJsonObject')
// .success(function (e) {
// $scope.SortItems = e;
// });
$scope.SortItems = JSON.parse('[{"Title":"ddddddd","MapId":5,"Order":0},{"Title":"Moje mapa","MapId":3,"Order":2},{"Title":"asdas","MapId":4,"Order":3},{"Title":"asds","MapId":7,"Order":4},{"Title":"Pokus","MapId":8,"Order":5},{"Title":"Hello world!!!","MapId":1,"Order":10}]');