Reputation: 15200
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?
Upvotes: 0
Views: 49
Reputation: 16498
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>
Upvotes: 1