I am used to Asp.Net MVC Views and working with Modals. You can easily create a Shared Modal template and reuse that over and over by passing in PartialViews with ViewBags, TempData, hidden inputs etc... using JavaScript.
I am new to Angular and I'm using Bootstrap 4. I can easily create a Modal that will create something like an employee object, but I can't figure out a good way to edit that object, using a Modal. I can create an Edit Modal and use something like JavaScript to populate the data, but I can't pass all the form data on a button click nor can I pass all the data like Ids, using hidden fields.
The solution seems to be installing a package like ngBootstrap in order to leverage a Modal service that will allow me to pass in the employee object when opening an Edit Modal. If so, I will need to refactor my application to use ngBootstrap since it doesn't seem to play well with JavaScript, jQuery and the native Bootstrap implementation. I will also have to build modals and modal containers that I don't see how can be reused.
If I use a Modal service, will it magically bind all the elements of the employee object and pass all the data (including any edits and Ids) when I click the save button? Seems like this is the real benefit of Angular.
Do I need to install something like ngBootstrap to get this basic functionality?
Are there better ways to do this in Angular 8?
UPDATE 1
I would expect this.formModel = content to actually populate data in the Modal, but it does not. If I use this.formModel.Name = "Test Name", that works.
this.service.findContent(id).subscribe(
res => {
var content = res as Content;
let content2 = Object.assign(new Content(), res)
//Full object is visible in console
console.log('content', content);
//undefined in console
console.log('content2', content2.Name);
//Does not populate any data in the form
this.formModel = content;
//This will populate Test Name in the Name field on the form
this.formModel.Name = "Test Name";
//Just shows the Modal using Javascript
this.popModal(content);
},
err => {
console.log(err);
}
)
Any help is much appreciated. Thanks!