javascript - AngularJS ui-router resolve does not return custom value -
While trying to resolve some data before going to my page, I force the solution to resolve, Convert it to a custom object and I try to return a custom object to your object.
.state ("trip.detail", {url: '/: tripId', templateUrl: 'partial / trip / description html', controller: 'TripDetailController', resolution: {train data: Returns {TripService, $ State Page, $ Q} {TripService.getTripById ($ stateParams.tripId, Function (Data) {console.log ("Receive:" + Data); Return {"RETTATIENTID": Data. Uttar Pradesh, From ": New Date (data. Deperture). IOSTOT ()," To ": New Date (Data Arrival) .OOSOserting ()," Project ID ": Data POSIID," IsTrip ": True," tripId ": Data.id, "rectangle Pvkry ": data.tracejectory," statistics ": data.statistics}}). $ Promise;}}}); All this works, except the 'train', which is being injected into my controller, is actually 'data' and not a custom builder.
What's going on?
Additional information about TripService:
services.factory ('TripService', function ($ resource) {
function TripService () { TripResource = $ resource ('rest / trip /: trip id');} TripService.prototype.getTrips = function (start, end, project, train, callback) {return.trripsResource.query ({projectId: project, trainIds: TrainIds, to start: end}, callback)} TripService.prototype.getTripById = function (tripId, callback) {this.tripResource.get ({tripId: tripId}, callback);} New TripService () return; });
You must create your own promise and compile it with your custom object: < Pre .state ("trip.detail", {url: '/: tripId', templateUrl: 'partial / trip / description html', controller: TripDetailController ', resolution: {train data: function (trip service, $ state Page, $ Q) {var deferred = $ q.defer (); TripService.getTripById ($ stateParams.tripId, function (data) {console.log ("receive:" + data); Deferred.resolve ({"relativeTrainId" : Data.trainId, "From": New Date (Dataset) .toIString (), "To": New Date (data.arrival) .toISOStrin Data "," projectId ": data .projectId," isTrip ": true," tripId ": data.id," trajectory ": data. Spectrory," data ": data.statistics});}); refund suspended .}}});
Comments
Post a Comment