Comments (5)
Hey there,
I got a similar problem. I want to change the component-variable and render a new one in this tag.
When I am initializing the variable with different components it works fine.
Now I got this changeComponent function, but it is not working.
You can find this project in my repo: https://github.com/maadc/wir-app/blob/master/src/app/viewfield/viewfield.component.ts
import { Component} from '@angular/core';
import { LageplanComponent } from './lageplan/lageplan.component';
import { HomeComponent } from './home/home.component';
@Component({
selector: 'viewfield',
template: `<ndc-dynamic [ndcDynamicComponent]="component"></ndc-dynamic>`
})
export class ViewfieldComponent {
component = HomeComponent;
changeComponent(){
this.component = LageplanComponent;
}
}
from ng-dynamic-component.
If your goal is to change component type to render another component that is totally possible you just need to update the variable passed to ndcDynamicComponent
input.
But you have to make sure that change detection is triggered in case your parent components are in OnPush
mode.
from ng-dynamic-component.
I tried doing just that and didn't work.
Could you elaborate a little bit on the change detection, or point me in the right direction? This is literally my 2nd day with Angular
from ng-dynamic-component.
Well if you did not explicitly change your change detection for component then there is not point in worrying about that - it should just work.
If you can provide plunkr of what you trying to do it will be more helpful and I then can better understand and help you achieve what you want.
from ng-dynamic-component.
Closing due to inactivity.
from ng-dynamic-component.
Related Issues (20)
- Is this project abandoned? HOT 3
- Question about dynamic templates HOT 2
- Support RxJS ^7.4.0 HOT 2
- Support for Angular 14 HOT 7
- Need add rxjs 7 support for version 9.x.x HOT 14
- Building app with angular 13 leads to compile error HOT 6
- Outputs initialized after inputs which leads to missed events triggered synchronously from constructors/setters HOT 2
- Cannot access 'IoService' before initialization HOT 8
- Backwards compatibility with Angular 13 in minor update v10.x.x is broken HOT 1
- [Question] How to call functions mentioned in dynamic components HOT 2
- Support for Angular 15 HOT 4
- Ability to provide ngModuleRef when creating component HOT 4
- [BUG] `IoEventContextToken` is not exported HOT 3
- Unknown input error after updating from no-barrels version [Bug] HOT 1
- Property 'withComponents' does not exist on type 'typeof DynamicModule'. HOT 1
- Support angular 14 HOT 1
- Component not support nested HOT 2
- [Bug] HOT 2
- Support for Angular 16 HOT 3
- Angular 17 support HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ng-dynamic-component.