Create menu of a JSON file using Angularjs

Asked

Viewed 661 times

-1

I have a JSON file with the following extrusion:

"[{\"Menu\":\"General/Register/User\"},
{\"Menu\":\"App/MultiExport/Parameter\"},
{\"Menu\":\"App/MultiExport/CreateFile\"},
{\"Menu\":\"App/MultiCube/Create\"}]"

How do I create a menu using Angularjs from that JSON?

It is worth noting that each "/" is a level of submenu:

.General
      .Register
              .User
.App
      .MultiExport
              .Parameter
              .Create File
      .MultiCube
              .Create
  • It will be only 3 levels or more?

  • So, this JSON is returning from a webservice... For now we have 3 levels but new levels may arise.

  • This JSON structure can be changed?

1 answer

0

Opa Lucas,

First convert to a json, because the angular is thinking that it is a String and is placing these bars.

var novoJSON = angular.fromJson(objetoDoJson);

so you can play with the object and create the list you want.

The Javascript object will look like this:

[{Menu:"General/Register/User"},
{Menu:"App/MultiExport/Parameter"},
{Menu:"App/MultiExport/CreateFile"},
{Menu:"App/MultiCube/Create"}]

Browser other questions tagged

You are not signed in. Login or sign up in order to post.