- The selector property for a Component decorator does not have to be tag-named-based. '.whatever' will allow for <div class="whatever">swap me out</div> and '[whatever]' for <div whatever>swap me out</div>.
- btn btn-primary are some Bootstrap styles.
- FormsModule from @angular/forms may be required for: [(ngModel)]
- (input) is an event for an input fill-in-the-blank field.
- @Directive({
selector:'[whatever]'
})
export class DoSomething {
may be called out to like: <div whatever>swap me out</div> - <p *ngIf="hasCondition; else myHashtag">foo<p>
<ng-template #myHashtag>
<p>bar</p>
</ng-template>
...shows off an if/else at an *ngIf for the bar paragraph will show if not hasCondition. - Math.random() in JavaScript gives a decimal between zero and one that is... random.
- <p [ngStyle]="{backgroundColor: giveColorForBackground(), 'margin-left':'10px'}"> shows off ngStyle. Note that you are handing in a JSON object full of properties and each property is a style. If the property name has a hyphen you either have to give the name in camel case without the hyphen or wrap the name in quotes.
- <p [ngClass]="{whatever: myThing==='foo'}"> shows off ngClass. Here, again, a JSON object. Each property name is a class name and the value for each property is a conditional for whether or not to apply the class defined in the class name.
- <p *ngFor="let mouse of mice; let i = index"> shows off having an index variable at an *ngFor and this is actually not something that I learned from the training. I already knew this, but I found myself wondering if I had every included it at this blog. If not, here it is now.
Sunday, May 28, 2017
some stuff I learned from an Angular 4 training this weekend
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment