I'm using Salesforce. If the text is more than 25 characters, I'm limiting it to 25 characters and passing it to a <p>
. My question is how can I pass a class to it here?
doInit : function(component,event,helper) {
var address = component.get("v.studentAddress.Address");
if(address.length > 25) {
address = address.substr(0,25);
component.set("v.studentAddress.Address", address);
//how do I pass a class to this container?
}
}
You don't, here. You shouldn't store raw HTML and then inject it into your component. Instead, your component markup should contain the required HTML tags and reference the raw data in your component attribute:
<p> {! v.studentAddress.Address } </p>
If needed, you can use <aura:if>
to conditionally render elements of your markup based on the values of component attributes.