1

I just started working on a new project which was started.

The last dev was using vm, and I need to print some data

Here I have the ctrl

(function () {
  'use strict';

  angular
    .module('palpatine')
    .controller('RotationsCtrl', RotationsCtrl);

  /* @ngInject */
  function RotationsCtrl (Rotations, $rootScope, $state) {
    /*jshint validthis: true */
    var vm = this;
    vm.data = Rotations;

    console.log(vm.data);
   }
})();

than console.log(vm.data) returns an obj like this

[{
    "_id": "5653e0fee890e41700946a75",
    "name": "Mtg Rotation 112415 - SR",
    "group": {
      "_id": "563166b302d8831700dfc707",
      "object_name": "rotation",
      "name": "Mortgage",
      "__v": 0,
      "updated_on": "2015-10-29T00:22:11.868Z",
      "created_on": "2015-10-29T00:22:11.868Z"
    }, {
    "_id": "5653e0fe946a75",
    "name": "Mtg Rotation 112415 - JR",
    "group": {
      "_id": "700dfc707",
      "object_name": "rotation 2",
      "name": "Home Mortgage",
      "__v": 7,
      "updated_on": "2015-10-29T00:22:11.868Z",
      "created_on": "2015-10-29T00:22:11.868Z"
    }]

all I need is to render that data.name in an ul - li

let's say like this

  <ul class="dropdown-menu" dropdown-menu>
    <li ng-repeat="datum in vm.data.name">
      {{datum}}
    </li>
  </ul>

what can I do ?

1 Answer 1

1

You should loop through a vm.data then print name from the each object like datum.name.

Markup

<ul class="dropdown-menu" dropdown-menu>
    <li ng-repeat="datum in vm.data">
      {{datum.name}}
    </li>
</ul>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.