Hi! I'm a total Ng noob, so struggling with basics here.
Have a list of categories in a form and trying to pass a value from a
selected category so I would pass it further to a db.
That's my code for the form
Enter code here...
<div class="form-group">
<label>Category</label>
<select class="form-control" formControlName="categoryId">
<option *ngFor="let faq of allFAQ"
value="{{faq.categoryId}}">{{faq.category}}</option>
</select>
<p class="alert alert-warning"
[hidden]="form.controls.categoryId.valid ||
(form.controls.categoryId.pristine && !submitted)">
Category is a must!
</p>
</div>
That's my ts code for saving the info:
Enter code here..saveQ() {
var savedQ = new NewQuestion();
savedQ.newQ = this.form.value.newQ;
savedQ.topic = this.form.value.topic;
savedQ.category = this.form.value.category;
savedQ.categoryId = this.form.value.categoryId;
savedQ.email = this.form.value.email;
var body: string = JSON.stringify(savedQ);
var headers = new Headers({ "Content-Type": "application/json" });
this._http.post("api/faq", body, { headers: headers })
.map(returData => returData.toString())
.subscribe(
retur => {
this.retrieveAllNewQuestions();
this.showForm = false;
this.showFAQList = true;
this.showQList = true;
},
error => alert(error),
() => console.log("post-api/faq done")
);
};
Would really appreciate some help!
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.