0

I am making a view from json. I am able to that when I take json in a variable. But same thing when i read from file my view is not display. when comment the code which is working when I take json string in a variable.

Second issue

<div ng-switch-when="text" class="form-group">
    <input type="text" value='login name' ng-model="outputs[input.name]"/>
    <p ng-show="myfrm.input.$error.email && !myfrm.input.$pristine">Please enter a valid textl</p>
    <p ng-show="myfrm.input.$error.required && !myfrm.input.$pristine">Please enter the text</p>
</div>

When I am using static value of input field like that(value='login name').it doesn't display that field value in input field.actually there is parameter value in my json I want to show value in input field (it there is any value it should display with filled value).

I take value like that

"value":value.value,

plunker: http://plnkr.co/edit/f3ZNtPbKeFkXnOOc3PNM?p=preview

actually why i am ready from file because there mat 1000 json object .i need to make 1000 form using one method

can I used this function

function changeData(data) {

    var map = { NUMBER: "number", TEXT: "text", SWITCH: "select" };

    // data is an object - use for .. in to enumerate
    for (var key in data.input) {
        var e = data.input[key];   // alias for efficient structure dereferencing
        e.label = e.displayName;
        e.title = e.displayDetail;
        e.type = map[e.inputType];

        delete e.displayName;
        delete e.displayDetail;
        delete e.inputType;
    }

};

or I used this plugin https://github.com/danhunsaker/angular-dynamic-forms

Shruti
  • 1,554
  • 8
  • 29
  • 66
  • The issue is you are treating objects in your json as arrays, when they are not. – Zack Argyle Aug 10 '14 at 15:38
  • @ZackArgyle so how I change .can I check the keys.can you share your plunker – Shruti Aug 10 '14 at 15:40
  • [Plunker](http://plnkr.co/edit/btERGFoZu9oKNWADtl9x?p=preview). I changed the data to be an array, and moved the logic into the callback, because you were trying to use the data before it returned asynchronously. If you can't change the data, look at [This Answer](http://stackoverflow.com/questions/8312459/iterate-through-object-properties) about how to iterate an object. – Zack Argyle Aug 10 '14 at 15:43
  • yes .I don't want to change the json it is constant ..so I will go second option to iterate the object.And try if you get answer please post it .till I am trying – Shruti Aug 10 '14 at 15:50
  • @ZackArgyle please check update ..can I use this function – Shruti Aug 10 '14 at 16:00
  • @ZackArgyle do you know anything about this? – Shruti Aug 10 '14 at 16:11
  • or I used this plugin https://github.com/danhunsaker/angular-dynamic-forms – Shruti Aug 10 '14 at 16:30
  • any update of this Question – Shruti Aug 10 '14 at 22:19

0 Answers0