0

I am trying to display the json object at the end of the form like

    <p>
        <input type="text" name="title" ng-model="blog.title" />
    </p>
    <p>
        <textarea name="txt" ng-model="blog.txt"></textarea>
    </p>
    <p>
        <select name="type" ng-model="blog.type" ng-options="type.id as type.name for type in types" />
    </p>
    **{{blog}}**
    <br/>

</form>

but it displays the object not. but if I place the {{blog}} right after form open tag, then it works.

Any idea?

2
  • Instead of {{blog}} try {{types}} Commented Apr 9, 2015 at 11:48
  • can you provide a plunkr ? Commented Apr 9, 2015 at 11:51

2 Answers 2

1

You need to close select tag ie:

<select name="type" ng-model="blog.type" ng-options="type.id as type.name for type in types"></select>

please see demo below

var app = angular.module('app', []);

app.controller('homeCtrl', function($scope) {


  $scope.types = [{
    id: 1,
    name: "one"
  }]

});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<body>
  <div ng-app="app">
    <div ng-controller="homeCtrl">
      <form>

        <p>
          <input type="text" name="title" ng-model="blog.title" />
        </p>
        <p>
          <textarea name="txt" ng-model="blog.txt"></textarea>
        </p>
        <p>
          <select name="type" ng-model="blog.type" ng-options="type.id as type.name for type in types"></select>
        </p>
        {{blog}}
        <br/>

      </form>


    </div>
  </div>
</body>

Sign up to request clarification or add additional context in comments.

Comments

1

Have you tried with the json filter?

{{blog | json}}

Comments

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.