How to create two way binding in angularjs using JSON?

Actually my requirement is want to create form controls like textbox, dropdown, date/time picker etc..

The above controls i want create using JSON , I will have all the Meta Data in the form of JSON. Using that JSON i can able to create the controls using Angular Directive, Now i want to modify the any of the controls in the VIEW I need to change the Control as well as the JSON. Here i need to use two way binding.

Please anyone help me to achieve this or Provide any examples likewise.

Thanks in advance.

Answers


I'm not sure if I understand the question, but if you're just needing to convert an object literal on your scope to JSON, angular.toJson should fit your needs.

$scope.object = {
    foo: 'bar'
}

var result = angular.toJson($scope.object);

Bind $scope.object to your control using ng-model and use angular.toJson in your controller to convert the scope object to JSON to use elsewhere as needed.


Need Your Help

how to trim the white spaces before and after ":"

python

I am looking for some inputs on python coding. My input text file is like below

CSS Active link not working

html css

So I have a nav bar. Built using Zurb: