Reputation: 253
I'm trying to query data from mongodb database and display the data on a form, following is my json response, the data will not show in textarea but if replace textarea with input field the data is showing, the following does not work
<textarea rows="15" class="form-control" ngmodel="pageContent.content"></textarea>
it works if i replace textarea with input field
<input class="form-control" type="text" ng-model="pageContent.content" />
JSON data
{
"_id": "59f768a4f26ad23a7c6bfa3d",
"title": "test title",
"url": "test url",
"content": "test content",
"menuIndex": 4,
"date": "2017-10-30T18:00:04.113Z",
"__v": 0
}
View File
<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>
Pages Model
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;
Can someone please help me on this?
Upvotes: 0
Views: 79
Reputation: 222682
In some of the input you have ngmodel
change them as ng-model
<input class="form-control" type="text" readonly ng-model="pageContent._id" />
Upvotes: 2