我试图在表单的末尾显示json对象,如
<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>
但它不显示对象。但如果我在表单打开标记之后放置{{blog}}
,那么它就可以了。
有什么想法吗?
答案 0 :(得分:1)
您是否尝试过使用json filter?
{{blog | json}}
答案 1 :(得分:1)
您需要关闭选择标记,即:
<select name="type" ng-model="blog.type" ng-options="type.id as type.name for type in types"></select>
请参阅下面的演示
var app = angular.module('app', []);
app.controller('homeCtrl', function($scope) {
$scope.types = [{
id: 1,
name: "one"
}]
});
&#13;
<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>
&#13;