I can not display object data in the view that returns from $ http.get

0

I am getting data from an api via $ http request. This is my controller.

angular.module('supernovaWebApp',['ui.router'])
  .controller('professoresCtrl', ['$scope', '$http', function($scope, $http){
        $http.get("http://localhost:3000/api/instructors/"+instructorId).success(function(data,status){
          console.log(data);
          $scope.professor = data;        
        });
      };
  }])
  .config(function($stateProvider){
    $stateProvider.state('instructor', {
      url: '/instructor',
      templateUrl: 'views/instructor.html',
      controller: 'professoresCtrl'
    });
  });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

TheobjectreturnswithouterrorandIcanobservetheobjectintheconsole,butitdoesnotrenderintheview.

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script><div><divclass="mdl-cell mdl-cell--4-col">
    <div  class="mdl-card mdl-shadow--2dp">
      <div class="mdl-card__title">
        <h2 class="mdl-card__title-text">{{professor.name}} {{professor.last_name}}</h2>
      </div>
      <div class="mdl-card__supporting-text">
        <p>{{professor.profession}}</p>
        <i class="material-icons md-18">phone</i> {{professor.phone}}
      </div>
      <div class="mdl-card__menu">
        <button ng-click="delInstructor(instructor)" class="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect" >
          <i id="btn-archive" class="material-icons" >clear</i>
          <span class="mdl-tooltip" data-mdl-for="btn-archive">
            Arquivar
          </span>
        </button>
      </div>
    </div>
  </div>        
</div>

The strange thing is that when I make the same call to a list of objects, I can display them using ng-repeat, no problem. Does anyone know where I'm going wrong?

Print from the console. The object in question is id 1

    
asked by anonymous 13.01.2017 / 02:23

0 answers