Angularで作るER DIAGRAM TOOL – 第七回 モデル修正・削除機能の実装。およびER図エリアへの表示

Create a component for the model to display in the left column.


· Input is imported to inherit model from appComponent.
· The method editModel () is described to open the model modal
· The method deleteModel () confirms with the confirm window and then calls the deleteModel () method of dataService.
By the way, dataService.editModel () is not necessary because it is bi-directional binding, it is changed from input as soon as possible.


· Add deleteModel () method.

Before modifying model.component.html, add two methods to the model class.


· GetElementId () … Returns a character string like 'model1’. Used for id name of model on html.
· GetElementH2Id () … Returns a character string such as “model1 – h2". It is used for the id name of H2 of model on html.


· The class name is separated by the is_pivot property of model. I use is_pivot much later, so I do not mind for the time being.
[class.list – group – item – primary] = “myModel.is_pivot === false" [class.list – group – item – secondary] = “myModel.is_pivot === true"

※ pivot is an intermediate model (table) that can be created between a model and a model when creating a many-to-many relationship.


· Tentatively blank

Once ready, load it into module.


· Import ModelComponent


· Read the model component in the left column area.
<model * ngFor = “let model of data.models" [myModel] = “model"> </ model>
· Let’s memorize the form by repeating * ngFor.
· Pass [myModel] the data to the child component. Remember to @Input () myModel; on the child component side

Here, preview confirmation.


Since the characters are extremely big, adjust the font size.


· I want to apply to all the following model (also to Schema component part to be added later), so I write it in top level css.


This adds, modifies, and deletes models.

Next time, we will implement Schema addition, editing and deletion.