angular2-template

Angular 2 SVG not rendering

微笑、不失礼 提交于 2020-12-11 02:37:10
问题 I created a component to render SVG images that are within my app. The are loaded dynamically as the however, my demo app just show a simpler version. http://plnkr.co/edit/g2tZXeUAMJ5zESx2EHT0?p=info i tried <div [innerHTML]="data"></div> and <div> {{ data }} </div> The SVG is not being loaded though the call is correct. I spent sometime in gitter to find a solution but the closest i got was it it's being sanitzed. The innerHTML i assume is being sanitzed and the interpolation is being

How to set attribute d pf path element in Angular 2?

ぃ、小莉子 提交于 2020-07-30 14:59:33
问题 I am working on a Angular2 Project. class Coordinate { x:number; y:number; } class Data { ..... coordinates: Array<Coordinate>; ......... } This is a service file. I am using this service to access data in my Component's .ts file. I want to use coordinates array to draw polyline on svg. In the template file, I am trying to set attribute 'd' of path element but can't figure out the right syntax to do so. Following is the section of .html file of the component <div> <svg> <path [[How am I

How to access ViewChild reference defined on parent component - Angular 2

眉间皱痕 提交于 2020-07-18 20:26:29
问题 I have a spinner/loader element defined in app template (root component's template) like <!--I have it here so that I don't have to paste it in all my templates--> <div #spinner></div> In my child components, I am trying to access it using @ViewChild but that seems to always return undefined. My code for accessing this in child component is @ViewChild('spinner', { read: ViewContainerRef }) container: ViewContainerRef; //this is always undefined However when I place my #spinner in my child

How to access ViewChild reference defined on parent component - Angular 2

[亡魂溺海] 提交于 2020-07-18 20:21:28
问题 I have a spinner/loader element defined in app template (root component's template) like <!--I have it here so that I don't have to paste it in all my templates--> <div #spinner></div> In my child components, I am trying to access it using @ViewChild but that seems to always return undefined. My code for accessing this in child component is @ViewChild('spinner', { read: ViewContainerRef }) container: ViewContainerRef; //this is always undefined However when I place my #spinner in my child

Angular 2 image src as function return

狂风中的少年 提交于 2020-07-18 11:01:59
问题 In my Angular 2 application i have a list of users "Users:any" wich contain the properties : name, job, age...etc , the problem is that to get the profile image i have to get the the id from of the image from the Users object, then use a web service getImage(ImageId), so i have this in my html <div *ngfor="let user of users"> <img [src]="getImage(user.profileImageId)"/> In this case, i can't get the profile image displayed, i think the html is loading before the data ? any help? 回答1: Just try

Angular 2 image src as function return

左心房为你撑大大i 提交于 2020-07-18 11:01:25
问题 In my Angular 2 application i have a list of users "Users:any" wich contain the properties : name, job, age...etc , the problem is that to get the profile image i have to get the the id from of the image from the Users object, then use a web service getImage(ImageId), so i have this in my html <div *ngfor="let user of users"> <img [src]="getImage(user.profileImageId)"/> In this case, i can't get the profile image displayed, i think the html is loading before the data ? any help? 回答1: Just try

Using 'this' keyword in Angular component's template

百般思念 提交于 2020-07-18 06:37:09
问题 Let's say we have a prop variable in the component class and we use it via interpolation in the template (stackblitz demo): component class: @Component({...}) export class AppComponent { prop = 'Test'; ... } template: <p>{{ this.prop }}</p> <p>{{ prop }}</p> Why in Angular it's possible to use this keyword in templates without any warnings/error (even in AOT mode)? What's behind it? Edit According to the remark in the answer: this refers to the component itself for which the template was

host-context not working in Angular

两盒软妹~` 提交于 2020-06-27 12:45:15
问题 The button background is red, when it should be green i.e. the conditional styling controlled by :host-context is not activated? Child component styles commander.scss commander { button { background-color: red; } :host-context(.enough-space) .btn-theme { background-color: green; } } Child component template commander.html <button class="btn-theme" (click)="demand()">{{requestText}}</button> Host component template front.html ... <commander (command)="requestPage()" [requestText]="requestText"