我试图从mongodb数据库查询数据并在表单上显示数据,以下是我的json响应,数据不会显示在textarea中,但如果用输入字段替换textarea数据显示,则以下不起作用
<textarea rows="15" class="form-control" ngmodel="pageContent.content"></textarea>
如果我用输入字段替换textarea
,它会起作用<input class="form-control" type="text" ng-model="pageContent.content" />
JSON数据
{
"_id": "59f768a4f26ad23a7c6bfa3d",
"title": "test title",
"url": "test url",
"content": "test content",
"menuIndex": 4,
"date": "2017-10-30T18:00:04.113Z",
"__v": 0
}
查看文件
<h1>{{heading}}</h1>
<hr/>
<form role="form" id="add-page" ng-submit="savePage()">
<div class="form-group">
<label>Page ID</label>
<input class="form-control" type="text" readonly ngmodel="pageContent._id" />
</div>
<div class="form-group">
<label>Page Title</label>
<input class="form-control" type="text" ng-model="pageContent.title" />
</div>
<div class="form-group">
<label>Page URL Alias</label>
<input class="form-control" type="text" ng-model="pageContent.url" />
</div>
<div class="form-group">
<label>Menu Index</label>
<input class="form-control" type="number" ng-model="pageContent.menuIndex" />
</div>
<div class="form-group">
<label>Page Content</label>
<textarea rows="15" class="form-control" ngmodel="pageContent.content"></textarea>
</div>
<input type="submit" class="btn btn-success" value="Save">
</div>
</form>
页面模型
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var Page = new Schema({
title: String,
url: { type: String, index: { unique: true } },
content: String,
menuIndex: Number,
date: Date
});
var Page = mongoose.model('Page', Page);
module.exports = Page;
有人可以帮我解决这个问题吗?
答案 0 :(得分:2)
在某些输入中, * Trying ::1...
* Connected to localhost (::1) port 9000 (#0)
* Server auth using Basic with user 'deb3dd4152c571bcdb7b965e1d99b23a4e5c9505'
> POST /api/qualityprofiles/copy HTTP/1.1
> Host: localhost:9000
> Authorization: Basic ZGViM2RkNDE1MmM1NzFiY2RiN2I5NjVlMWQ5OWIyM2E0ZTVjOTUwNTo=
> User-Agent: curl/7.49.1
> Accept: */*
> Content-Length: 179
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=------------------------c22bb5dd76f44ac4
>
< HTTP/1.1 100
< HTTP/1.1 400
< Content-Type: application/json
< Content-Length: 56
< Date: Wed, 04 Oct 2017 00:43:47 GMT
< Connection: close
<
* Closing connection 0
{"errors":[{"msg":"The 'toName' parameter is missing"}]}
将其更改为 ng-model
ngmodel