Questions tagged [angular2-ngcontent]

94 questions
0
votes
1 answer

Angular6 transclusion / content projection: better conditional on wrapping html

I want to render my rather simple component always with a default and optionally with a named ng-content. If that named ng-content exists, it should be wrapped by additional html. I did find a a solution, but annoyingly I need two…
Frank N
  • 9,625
  • 4
  • 80
  • 110
0
votes
1 answer

Angular - template reference on ng-content

I need to render dynamic content around an input in Angular app. My idea was to create a custom component, and then use ng-content to bind the behavior to that input. Like so:
dzenesiz
  • 1,388
  • 4
  • 27
  • 58
0
votes
2 answers

canvas not displaying in ng-template in Angular

I'm using Angular 8 I have a canvas element which has to be displayed in different child components inside the parent component but the data on it should be same. To resolve this situation, I used ng-content in the child components like Component A…
Anuj TBE
  • 9,198
  • 27
  • 136
  • 285
0
votes
0 answers

ng-content selector not being read when html is in a child component

Suppose I have the following component (let's call it "MyModalComponent") MyModalComponent
Tim Geerts
  • 311
  • 5
  • 14
0
votes
1 answer

How to bind data in ngStyle using Angular

I'm trying to bind data using Angular 8 but failing miserably. One of the methods I tried is as below:
and…
Elaine Byene
  • 3,868
  • 12
  • 50
  • 96
0
votes
0 answers

The component inside ng-content is instantiated twice

I am using Angular 4 and I have a component 'X' which is basically a collapse-expand component. It wraps whatever is provided to it and collapse and expand it on clicking. It looks similar to below one.
// some X related DOM here …
0
votes
0 answers

ion-select not updated when is inside then ng-content of custom component

I've a ionic page with a ion-select inside a custom component that shows itself when a flag isLoading is true. The ion-change callback makes a network request using an Observable, the first operation the callback does is setting the isLoading flag…
david
  • 3
  • 2
0
votes
0 answers

Angular does not render html in typescript

I code some html in my component like below. I add span with specific class in renew innerHTML of an element: nodes = this.getAllTextnodes(this.textarea.nativeElement); x1 = nodes[0].data.substring(0, this.characterLimit - 1); …
Mohandes
  • 271
  • 3
  • 6
  • 17
0
votes
1 answer

Angular 2+ Content Projection and Component property binding

I'm stuck on a hard stuff about Angular Content Projection. I would like to project a component A into another one B and bind some properties on the component A. For example, I have a SwitchButton component (with several choices). I want this…
Canopy
  • 51
  • 7
0
votes
1 answer

Angular 4,5 how to detect for ng-content in child component to be finished changing

I have a parent component like this. So number of items in menu depends on model. And model changes. ... some data .... some data
0
votes
0 answers

How can you reuse an Angular reactive form inside other Angular reactive forms to stay DRY?

I have two forms in my Angular app: Form A (form for site admin) and Form U (form for standard user). Form A includes all of Form U but adds a few more input fields. I want to write Form U only once and use it both in Form U and Form A rather than…
0
votes
0 answers

passing array item back to component (ng-content) (angular) (custom component)

This might be a simple projection recipe, but I haven't been able to find the answer, the simple question is I have a loop with an ng-content in it, so lets say custom-component has this in its view file
0
votes
2 answers

Programmatically set content of a component in angular 2

I have created a simple window component that has a header and shows some content. My app will only ever show one window at a time, so I placed it in the root of my app and only change its contents when needed. As I need to be able to set the window…
0
votes
1 answer

Passing template to swimlane/ngx-datatable

I am using swimlane/ngx-datatable component and I developed a wrapper for ngx-datatable.  Wrapper:
Use:
puppeteer701
  • 1,225
  • 3
  • 17
  • 33
0
votes
1 answer

Trying to reduce code repetition in my code base

I'm trying to reduce code repetition in my code base, where I have the following pattern in my HTMLs: {{entityFormName}}