user3871494
user3871494

Reputation: 91

Angular ng-repeat doesn't work correctly

When I load the index.html page on local host by hitting localhost:3000/#/ . I can see the template is getting loaded in the network tab of the browser and I can also see that the controller is working fine in the console(by logging). However, the page remains blank. To my surprise if I append anything after the url like localhost:3000/#/xyz and refreshes I can see the whole page loads perfectly.

Here is my code of routing:

angular.module('myApp', ['myApp.controllers',
  'ui.router'
]).config(function($stateProvider, $urlRouterProvider) {
    $urlRouterProvider.when('', '/');
    $stateProvider
    .state('app', {
        url: '/',
        templateUrl: 'app/dashboard.html',
        controller: 'DashCtrl'
    })
});

When the page remains blank, I can see the nothing inside the class wrap of template while loading the page.

<div class="wrap">
  <div ng-repeat="category in results track by $index" class="box"> 
    <a href="#/list/{{category.get('categoryName')}}">  
    </a>
  </div>
</div>

Upvotes: 1

Views: 88

Answers (1)

ExpectoPatronum
ExpectoPatronum

Reputation: 507

If your data is coming from some service, you can try using $scope.$apply() in your service success call back function once you set data on your scope variable.

This will bind the data to your view.

Upvotes: 1

Related Questions