How to access the body from a component

Asked
Active3 hr before
Viewed126 times

2 Answers

component
90%

Refer angular component styles,Angular applications are styled with standard CSS, That means you can apply everything you know about CSS stylesheets, selectors, rules, and media queries directly to Angular applications

Example_snippet/controller/utility/_component.js/ @Component({ selector: 'app-. . .
@Component({
  selector: 'app-root',
  template: `
    <style>
      body {
        overflow-y: hidden;
      }
    </style>
  `
})
load more v
88%

@Praveen, yes, this is totally normal, Here is what is happening:,When we say that the body attribute is defined on all components we mean that it's defined on the base <aura:component/> from which all components inherit

Example_snippet/controller/utility/_component.js/ <aura:component/> <aura:att. . .
<aura:component/>
   <aura:attribute name="body" type="Aura.Component[]"/>
   {!v.body}
</aura:component>
Step 2 continued with <aura:component> <div>Body. . .
<aura:component>
    <div>Body part</div>
    <ui:button label="Push Me" press="{!c.printCmpBody}"/>
</aura:component>
Step 3 continued with <c:myComponent> <i>Instance. . .
<c:myComponent>
   <i>Instance Part</i>
</c:myComponent>
Step 4 continued with <c:myComponent> <aura:set . . .
<c:myComponent>
   <aura:set attribute="body>
       <i>Hello</i>
    </aura:set>
<c:myComponent>
Step 5 continued with <aura:component> <div>Body. . .
<aura:component>
    <div>Body part</div>
    {!v.body}
    <ui:button label="Push Me" press="{!c.printCmpBody}"/>
</aura:component>
Step 6 continued with v.body = <i>Instance Part</i> . . .
v.body = <i>Instance Part</i>
+
lexical scope = <div>Body part</div>{!v.body}...
=
Rendered: <div>Body part</div><i>Instance Part</i>...
load more v