1

I have my two object

{
  "twitter": {
    "username": "potus",
    "postslimit": 10
  },
  "enum": [],
  "publicationdate": "2018-08-27T15:05:55.410Z",
  "_id": "5b8414ec3412b43a34f050cf",
  "clicks": [],
  "active": true,
  "user": " __ ",
  "type": "twitter",
  "__v": 0
}

If I dislay:

<a 
  class="twitter-timeline" 
  data-tweet-limit="2" 
  href="https://twitter.com/{{tw.twitter.username}}">
</a>

everything works fine, but when I'm trying to bind the data-tweet-limit like this:

<a 
  class="twitter-timeline" 
  data-tweet-limit="{{tw.twitter.postslimit}}"
  href="https://twitter.com/{{tw.twitter.username}}">
</a>

I get:

Can't bind to 'tweet-limit' since it isn't a known property of 'a'. ("'"> ]data-tweet-limit="{{tw.twitter.postslimit}}" href="https://twitter.com/{{tw.twitter.username}}">

(I'm loading the twitter timeline like this thread)

SiddAjmera
  • 38,129
  • 5
  • 72
  • 110
tam992
  • 13
  • 1
  • 6
  • Are you sure the `data-tweet-limit` is an attribute on the anchor tag? I'm not able to see it here: https://publish.twitter.com/?query=https%3A%2F%2Ftwitter.com%2FTwitterDev%2Ftimelines%2F539487832448843776&widget=Grid – SiddAjmera Aug 27 '18 at 16:06
  • @SiddharthAjmera thank you for replying , and yes, for example in the link you sent if you click "set customization options" you can see it, and also if I set it with a static default like data-tweet-limit="2" it works and prints only 2 tweets, I think the problem is that Angular doesent want to bind this attribute because it's not a default anchor attribute – tam992 Aug 27 '18 at 16:10
  • 2
    Possible duplicate of [How to bind to data-\* attribute in angular2?](https://stackoverflow.com/questions/34412103/how-to-bind-to-data-attribute-in-angular2) – SiddAjmera Aug 27 '18 at 16:15

1 Answers1

6

Here is a post explaining how to use data attributes

How to bind to data-* attribute in angular2?

Basically, you should use the following

[attr.data-tweet-limit]="tw.twitter.postslimit"
Santiago Robledo
  • 1,202
  • 12
  • 9
  • 2
    Consider flagging the question the as Duplicate instead of answering the question to better comply with the Quality Standards of StackOverflow. – SiddAjmera Aug 27 '18 at 16:16