![]() ![]() Some people ask, how to get and save data? for that just added two variables lang and exp and bind them with ngModel and show the entered value in alert. One more thing: after clicking the save button it will remove all the controls, this is also due to the old version, please update with new version and everything will be ok. It is already deprecated, it is not needed anymore in new versions but I created plunker with old version so. If you open the file we added something entr圜omponents: ![]() Var expComponent = (comp) ĮxpComponent.instance._ref = expComponent Var comp = this._cfr.resolveComponentFactory(ExpComponent) Web will see latter how this._ref will be assigned, here is the complete code for component: import Let's add one variable in this component say _ref: any, add the remove button code like this: // method to remove the component from parent page Problem here is how to remove the component from another component, we would not have access to that component code, right? What is remove button here? To remove the complete component from parent page. If you notice, we have two buttons, save and remove. Since we are learning how to add and remove component to another component, we are not binding the model and saving the data, I know you can easily do it. For clarity, we will use html and ts files separately, so create and HTML file named and add following code to it Let's create a new component called ExpComponent which we will use to dynamically add on any page. Here is the image, which we are going to code: It's better to write on plunker so we can test at anytime from anywhere. In this article we are going to see how to add, remove experience component to any other component, we will also try to pass some values to component from parent to child component to see if it is possible or not. Regardless of using Nx Console (or your IDE): run npx nx init from the root of your project.Angular 2 gives full control to add or remove component in other component programmatically by simple steps.If you're using Nx Console: open the Vs Code command palette and start typing "Convert Angular CLI to Nx Workspace".If you're not ready to make the change yet, you can come back to this later: Reverting this commit will effectively undo the changes made. Once the script has run, commit the changes. Creates an nx.json file in the root of your workspace.īy running this command and accepting Nx Cloud, Nx distributed caching is now enabled. ![]()
0 Comments
Leave a Reply. |