Answer the question
In order to leave comments, you need to log in
How to load controller before directive?
How to load directive before controller?
(function () {
var app = angular.module('app',["all-directive"]);
app.controller('pustTextCtrl', function($scope, $http){
$http.get("json/data.json").success(function(data){
$scope.data = data;
});
});
}();
(function () {
var app = angular.module('all-directive',[]);
app.directive('anyDirective', function(){
return {
restrict: 'A',
link: function($scope, elem, iAttrs, controller) {
alert(elem.children());[] // пустой массив /а нужны данные
}
};
});
})();
Answer the question
In order to leave comments, you need to log in
1. Use CODE tags.
It's much easier to read the source code this way... amazing
(function () {
var app = angular.module('app',["all-directive"]);
app.controller('pustTextCtrl', function($scope, $http){
$http.get("json/data.json").success(function(data){
$scope.data = data;
});
});
}();
(function () {
var app = angular.module('all-directive',[]);
app.directive('anyDirective', function(){
return {
restrict: 'A',
link: function($scope, elem, iAttrs, controller) {
//alert(elem.children());[] // пустой массив /а нужны данные
$scope.$watch('data', function(newData){
if(newData) { // первый раз watch вызовется когда ajax данные еще не придут
alert(newData); // пользуйтесь
}
});
}
};
});
})();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question