S
S
shnicel2015-01-03 15:42:28
JavaScript
shnicel, 2015-01-03 15:42:28

Where is the mistake? can't output value to given div id?

<script>
  var app = angular.module('app',[]);
    app.controller("profileCtrl", function($scope){
      var req="https://api.vk.com/method/users.get?user_ids=1"
      $.ajax({
          url : req,
          type : "GET",
          dataType : "jsonp",
          success : function(msg){
          console.log(msg.response[0].first_name);	
          $scope.resp = msg.response[0].first_name;
          }
      });
    });
</script>

<body ng-app="app">
  <div class="container">
    <div class="profile" ng-controller="profileCtrl">
      <div id="First_name">{{ resp }}</div>
      <div id="Last_name"></div>
      <div id="City"></div>
      <div id="Avatar"></div>
    </div>
  </div>
</body>

It outputs to the console, but in First_name it doesn’t matter, what’s wrong, if I just started learning angular

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Samsin, 2015-01-03
@psixodyb

var myApp = angular.module('myApp',[]);

myApp.controller('profileCtrl', ['$scope', function($scope){
      var req="https://api.vk.com/method/users.get?user_ids=1"
      $.ajax({
          url : req,
          type : "GET",
          dataType : "jsonp",
          success : function(msg){
          console.log(msg.response[0].first_name);	
          $scope.resp = msg.response[0].first_name;
          }
      });
    }]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question