Newer Version Available
forceChatter:feed
A forceChatter:feed component represents a feed that's specified by its type. Use the type attribute to display a specific feed type. For example, set type="groups" to display the feed from all groups the context user either owns or is a member of.
1<aura:component implements="force:appHostable">
2 <forceChatter:feed type="groups"/>
3</aura:component>You can also display a feed depending on the type selected. This example provides a drop-down menu that controls the type of feed to display.
1<aura:component implements="force:appHostable">
2 <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
3 <aura:attribute name="type" type="String" default="News" description="The type of feed" access="GLOBAL"/>
4 <aura:attribute name="types" type="String[]"
5 default="Bookmarks,Company,Files,Groups,Home,News,People"
6 description="A list of feed types"/>
7 <h1>My Feeds</h1>
8 <ui:inputSelect aura:id="typeSelect" change="{!c.onChangeType}" label="Type"/>
9 <div aura:id="feedContainer" class="feed-container">
10 <forceChatter:feed />
11 </div>
12</aura:component>The types attribute specifies the feed types, which are set on the ui:inputSelect component during component initialization. When a user selects a feed type, the feed is dynamically created and displayed.
1({
2 // Handle component initialization
3 doInit : function(component, event, helper) {
4 var type = component.get("v.type");
5 var types = component.get("v.types");
6 var typeOpts = new Array();
7
8 // Set the feed types on the ui:inputSelect component
9 for (var i = 0; i < types.length; i++) {
10 typeOpts.push({label: types[i], value: types[i], selected: types[i] === type});
11 }
12 component.find("typeSelect").set("v.options", typeOpts);
13 },
14
15 onChangeType : function(component, event, helper) {
16 var typeSelect = component.find("typeSelect");
17 var type = typeSelect.get("v.value");
18 component.set("v.type", type);
19
20 // Dynamically create the feed with the specified type
21 $A.componentService.newComponentAsync(
22 this,
23 function(feed){
24 var feedContainer = component.find("feedContainer");
25 feedContainer.set("v.body", feed);
26 },
27 {
28 componentDef : "markup://forceChatter:feed",
29 attributes : {
30 values : {
31 type: type
32 }
33 }
34 }
35 );
36 }
37})The feed is supported for the Salesforce1 app only. You can include this feed in a component and access it in the Salesforce1 app. If used outside of Salesforce1, you may encounter issues with dead links, unhandled events, and missing styles. For a list of feed types, see Working with Feeds and Feed Elements in the Chatter REST API Developer's Guide.
Attributes
| Attribute Name | Attribute Type | Description | Required? |
|---|---|---|---|
| body | Component[] | The body of the component. In markup, this is everything in the body of the tag. | |
| subjectId | String | For most feeds tied to an entity, this is used specified the desired entity. Defaults to the current user if not specified | |
| type | String | The strategy used to find items associated with the subject. Valid values include: News, Home, Record, To. |