admin管理员组文章数量:1026989
I am trying assign unique id to my bootstrap modal as it's being using ngFor. Following is my code.
<div class="container shadow lead-container" data-toggle="modal" [attr.data-target]="customId"> -------------------------> . Data-target is set to customId
<div class="row text-left">
----------------------> Other Content goes here
</div>
</div>
<!--Lead Popup-->
<div class="modal fade" [attr.id]="customId" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true"> -----------> [attr.id] is set to customid
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="container popup-container">
<div class="row text-left">
-------------------------------------> Modal Content Goes Here
</div>
</div>
</div>
</div>
Following is my ponent.ts:
import { Lead } from './../models/lead';
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'app-lead',
templateUrl: './leadponent.html',
styleUrls: ['./leadponent.css']
})
export class LeadComponent implements OnInit {
@Input() public lead: Lead;
@Input() public index;
public customId: string;
constructor() {
}
ngOnInit() {
this.customId = "custom".concat(this.index);
}
}
When i click on div. The modal doesnt popup for some reason. Any help would be much appreciated
I am trying assign unique id to my bootstrap modal as it's being using ngFor. Following is my code.
<div class="container shadow lead-container" data-toggle="modal" [attr.data-target]="customId"> -------------------------> . Data-target is set to customId
<div class="row text-left">
----------------------> Other Content goes here
</div>
</div>
<!--Lead Popup-->
<div class="modal fade" [attr.id]="customId" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true"> -----------> [attr.id] is set to customid
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="container popup-container">
<div class="row text-left">
-------------------------------------> Modal Content Goes Here
</div>
</div>
</div>
</div>
Following is my ponent.ts:
import { Lead } from './../models/lead';
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'app-lead',
templateUrl: './lead.ponent.html',
styleUrls: ['./lead.ponent.css']
})
export class LeadComponent implements OnInit {
@Input() public lead: Lead;
@Input() public index;
public customId: string;
constructor() {
}
ngOnInit() {
this.customId = "custom".concat(this.index);
}
}
When i click on div. The modal doesnt popup for some reason. Any help would be much appreciated
Share Improve this question asked Nov 15, 2019 at 8:39 Sumanth JoisSumanth Jois 972 silver badges9 bronze badges 7-
[id]="customId"
– Joel Joseph Commented Nov 15, 2019 at 8:54 - Can you please eloborate? I am new to angular – Sumanth Jois Commented Nov 15, 2019 at 8:54
- @JoelJoseph dint work tried it – Sumanth Jois Commented Nov 15, 2019 at 8:57
- have you pass the data of index – Muhammed Albarmavi Commented Nov 15, 2019 at 9:00
- I am setting the customId in ngOnInit(). And i am passing the data for index – Sumanth Jois Commented Nov 15, 2019 at 9:01
1 Answer
Reset to default 5add "#" to the id.
[attr.data-target]="'#'+customId"
I am trying assign unique id to my bootstrap modal as it's being using ngFor. Following is my code.
<div class="container shadow lead-container" data-toggle="modal" [attr.data-target]="customId"> -------------------------> . Data-target is set to customId
<div class="row text-left">
----------------------> Other Content goes here
</div>
</div>
<!--Lead Popup-->
<div class="modal fade" [attr.id]="customId" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true"> -----------> [attr.id] is set to customid
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="container popup-container">
<div class="row text-left">
-------------------------------------> Modal Content Goes Here
</div>
</div>
</div>
</div>
Following is my ponent.ts:
import { Lead } from './../models/lead';
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'app-lead',
templateUrl: './leadponent.html',
styleUrls: ['./leadponent.css']
})
export class LeadComponent implements OnInit {
@Input() public lead: Lead;
@Input() public index;
public customId: string;
constructor() {
}
ngOnInit() {
this.customId = "custom".concat(this.index);
}
}
When i click on div. The modal doesnt popup for some reason. Any help would be much appreciated
I am trying assign unique id to my bootstrap modal as it's being using ngFor. Following is my code.
<div class="container shadow lead-container" data-toggle="modal" [attr.data-target]="customId"> -------------------------> . Data-target is set to customId
<div class="row text-left">
----------------------> Other Content goes here
</div>
</div>
<!--Lead Popup-->
<div class="modal fade" [attr.id]="customId" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true"> -----------> [attr.id] is set to customid
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="container popup-container">
<div class="row text-left">
-------------------------------------> Modal Content Goes Here
</div>
</div>
</div>
</div>
Following is my ponent.ts:
import { Lead } from './../models/lead';
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'app-lead',
templateUrl: './lead.ponent.html',
styleUrls: ['./lead.ponent.css']
})
export class LeadComponent implements OnInit {
@Input() public lead: Lead;
@Input() public index;
public customId: string;
constructor() {
}
ngOnInit() {
this.customId = "custom".concat(this.index);
}
}
When i click on div. The modal doesnt popup for some reason. Any help would be much appreciated
Share Improve this question asked Nov 15, 2019 at 8:39 Sumanth JoisSumanth Jois 972 silver badges9 bronze badges 7-
[id]="customId"
– Joel Joseph Commented Nov 15, 2019 at 8:54 - Can you please eloborate? I am new to angular – Sumanth Jois Commented Nov 15, 2019 at 8:54
- @JoelJoseph dint work tried it – Sumanth Jois Commented Nov 15, 2019 at 8:57
- have you pass the data of index – Muhammed Albarmavi Commented Nov 15, 2019 at 9:00
- I am setting the customId in ngOnInit(). And i am passing the data for index – Sumanth Jois Commented Nov 15, 2019 at 9:01
1 Answer
Reset to default 5add "#" to the id.
[attr.data-target]="'#'+customId"
本文标签: javascriptAngular attrdatatarget and attrid not workingStack Overflow
版权声明:本文标题:javascript - Angular attr.data-target and attr.id not working - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745655584a2161580.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论