Sarang Khajuria Sarang Khajuria - 1 year ago 78
AngularJS Question

Loading data in ng-repeat after $http

I am trying to load a number of elements in a div from json via $http call. But whatever I try the list remains empty. Here is the code.

<div class="submenu" >
<div class="menuitem" ng-repeat="item in navigator" >{{item}}
<a href="#/main/welcome/{{item.messageId}}">{{item.label}}</a>

It is an abstract state and I have assigned controller greetingctrl to it in routes. The JS code is


$scope.list = [];

$scope.options.loading = false;
var currentmsg;
$scope.user = $cookieStore.get('userinfo');

$scope.init = function(){
var url = SERVICE.greetingMsg;
var data = {
providerID : $cookieStore.get('userinfo').providerId,
loginID : $cookieStore.get('userinfo').loginId,
action : "GET_MESSAGE"
$scope.navigator = res.messages;


Here I can successfully receive the data but the data in the list never comes. is $http method I have defined in a service.I am using angular 1.5.8 and I am new to angular.

EDIT: Removed ng-show and ng-if. Still the data is nnot showing

Answer Source

You need to check two variables:
- showmenu I don't see its value changing at all so it's always false.
- loadingisDone same as the previous.

And remember to call $scope.init somewhere.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download