2
$scope.form={
                Name:"",
                fields:[
                        {
                            id:"",
                            Name:"",
                            type:"dfsd",
                            order:""
                        }
                        ]
    };

How to access the type value in the above object.I need to push the value into it..i could not able to do..so first i thought to retrieve once I could not do..So can i have a solution for both the operations.Push and retrieve the value .

3

1 Answer 1

1

use this code:::

$scope.savebutton = function() {
  angular.forEach($scope.textboxes, function(text) {

    if (text != undefined && text.length != 0) {
      inputs = [];
      angular.forEach($scope.textboxes, function(t) {
        inputs.push(t);
      });
    }
  });
  var textfield = {
    id: "1",
    Name: "textbox"
  }


  $scope.form = {};
  $scope.form.fields = [];

  $scope.form.fields.push(textfield);
  console.log(angular.toJson($scope.form));
  ngDialog.closeAll();
};
Sign up to request clarification or add additional context in comments.

3 Comments

I am getting an error when i use that statement. Cannot read property 'push' of undefined
you are getting this error because you couldn't create '$scope.form.fields' before 'push'
you have to create "$scope.form.fields" before pushing.

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.