Czy istnieje sposób użycia $ compile z czystego javascript? Łączę podstawowy javascript z miejscami, w których używam Angulara i nie mogę znaleźć sposobu na zrobienie czegoś takiego: http://jsfiddle.net/DavidSlavik/bFdcJ/1/Inicjalizuj kontroler AngularJS po dołączeniu jakiegoś html do DOM
Myślę, że potrzebuję użyć $ compile, ale z miejsca, gdzie nie ma żadnego zakresu.
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}]');
Tak, to właśnie Potrzebuję!!! Dziękuję Ci bardzo!!! –
uratowało mi życie! Tesekkurler dostum! :) –
Znalazłem to po godzinie przeszukiwania bezużytecznych odpowiedzi na stackoverflow. Dziękuję Ci! – Aldekein