Hi Sander,
I have experimented hi and low and all seems to work just fine if I have
the app.js as you have designed it. As soon as I tried to separate the
concerns i.e. moving the service in it own file everything broke. Please,
see the plunker.
Where do I fail?
on my machine I have as such:
service.js
(function() {
var GetData = function($http) {
var prom = $http.get('data.js');
prom.success(function(data) {
prom.loadedData = data;
});
return prom;
};
angular.$inject = ['$http'];
angular.module('plunker')
.service('GetData', GetData);
}());
controller.js
(function() {
function crl($scope, GetData) {
$scope.test = GetData.loadedData;
};
angular.module('plunker')
.controller('crl', crl);
}());
and index.html
<body ng-controller="crl">
<div>
<b>$http with callback:</b>
<br>
<h3>I'm only vissible after loading</h3>
<pre>{{test|json:true}}</pre>
</div>
</body>
It is so painful not to understand where my logic breaks in fact.
Please, do help me get out of this mess.
On 26 September 2014 18:11, Sander Elias <[email protected]> wrote:
> Hi Constantinescu,
>
> Ah, I see what your problem is. Well, to get the data 'out' of the promise
> structure, you need to add an extra layer.
> Here is an example of that:
> http://plnkr.co/edit/mjCmj6cDi4GpDHI8RFs0?p=preview
>
> Is this what you where looking for?
>
> Regards
> Sander
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "AngularJS" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/angular/d1W5J3qPYX0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>
--
Constantinescu Nicolaie
Information Architect
http://www.kosson.ro
Membru în BEX al ANBPR
www.anbpr.org.ro <http://www.anbpr.org.r>
Director
http://sparceurope.org/
Open Acces Understanding
http://startad.kosson.ro
Information Science Sonar
http://sonar.kosson.ro
digital curator for Nostrum Monumentum
http://memoria.kosson.ro
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.