The .success method in $http is identical to the .then method, but the .then method follows the standard promise terminology. It's a good idea to get to know how promises work, and that you can use $http calls with other promise stuff (promise#all, etc). As I understand it, the .success stuff is there because angular kind of predates the A+ promise spec.
Eric On Mon Dec 08 2014 at 12:37:08 AM Fábio Alexandre <[email protected]> wrote: > @Sean Walsh, I'm new to angular. Could you explain what is the advantage > of using promise instead of success? > > Em sábado, 6 de dezembro de 2014 07h50min53s UTC+2, Sean Walsh escreveu: > >> First thing is to check the url is returning the data. If I navigate to >> that url, the name doesn't resolve. Does it work when you're running it? >> Check in the Network tab of your browser's developer tools: click on the >> url of the Get request and check in the results that the data is actually >> returned. >> >> Also, try use the promise instead of success. So I'd use >> get().then(function(data){ ...code here...}) >> >> rather than the >> get().success(function(data){}) >> >> that you're currently using... >> >> >> On Saturday, 6 December 2014 04:30:34 UTC+2, Sriram Varadarajan wrote: >>> >>> Here is my code: >>> >>> var myevents = angular.module('myeventsApp', []); >>> >>> myevents.controller("EventsController", function ($scope, $http) { >>> $http.get('http://mugh-events.azurewebsites.net/api/events/'). >>> success(function (data) { >>> $scope.events = data; >>> }); >>> }); >>> >>> <!DOCTYPE html><html><head> >>> <link rel="stylesheet" >>> href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css"> >>> <script >>> src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.9/angular.min.js"></script></head><body >>> ng-app="myeventsApp"> >>> <div ng-controller="EventsController" class="container"> >>> <h1>Events</h1> >>> <hr/> >>> <div ng-repeat="event in events" class="col-md-6"> >>> <h4>{{event.Name}}</h4> >>> <p>{{event.Description}}</p> >>> </div> >>> </div></body></html> >>> >>> I not getting any result.. Please suggest me.. >>> >>> >>> -- > 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. > -- 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.
