angularjs - Can't reach field inside an object in my angular controller -


i'm using factory television show database. wanted send episodes field object angular service keep getting undefined using dot notation , bracket notation. can explain how field.

controller

angular.module('showapp.controllers', []).controller('showviewcontroller', function($scope, $stateparams, show, $http) {   $scope.show = show.get({ id: $stateparams.id }); //get single show.issues /api/shows/:id    console.log($scope.show)   console.log($scope.show.episodes) }) 

console output

m $promise:d $resolved:true __v:0 _id:"581a5b82ff9e9f10f22afff7" airs_on:array[1] episodes:array[11] genre:array[3] network:"netflix" poster:"https://images-na.ssl-images-amazon.com/images/m/mv5bmtk5ntk1mzg3ml5bml5banbnxkftztcwndaynzy3oa@@._v1._cr25,3,1010,1343_sy1000_cr0,0,752,1000_al_.jpg" program_time:60 rated:"tv-ma" streams_on:array[3] title:"black mirror" yearbegin:2011 __proto__:object  undefined 

you can wait results by:

$scope.show.$promise.then(function(show) {   console.log(show.episodes); }) 

you should call service in then function.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -