5
मैं कुछ AJAX डेटा के साथ सुंदर प्रिंट का उपयोग करने की कोशिश कर रहा हूं। समस्या यह है कि जब निर्देश लागू किया जाता है, तो डेटा तैयार नहीं होता है, इसलिए मुझे अपरिभाषित परिवर्तनीय आउटपुट मिलता है।एंगुलरजेएस निर्देश एसिंक डेटा देख रहे हैं
Plunkr: http://plnkr.co/edit/fdRi2nIvVzT3Rcy2YIlK?p=preview
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope,$http) {
$scope.result = $http.get('data.json').success(function(result){
return result.data.dom
})
});
app.directive('prettyprint', function() {
return {
restrict: 'C',
link: function postLink(scope, element, attrs) {
element.html(prettyPrintOne(scope.result))
}
};
});
मैं plunkr नवीनीकृत किया है, लेकिन यह काम नहीं लगता है ... – Tropicalista
@Tropicalista मैं देखते हैं। मैंने अपना जवाब अपडेट कर लिया है, एक नज़र डालें – Cherniv