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

8
  • The issue is you are treating objects in your json as arrays, when they are not. Commented Aug 10, 2014 at 15:38
  • @ZackArgyle so how I change .can I check the keys.can you share your plunker Commented Aug 10, 2014 at 15:40
  • Plunker. 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 about how to iterate an object. Commented Aug 10, 2014 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 Commented Aug 10, 2014 at 15:50
  • @ZackArgyle please check update ..can I use this function Commented Aug 10, 2014 at 16:00

0

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.