博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ngRx 官方示例分析 - 5. components
阅读量:6933 次
发布时间:2019-06-27

本文共 2401 字,大约阅读时间需要 8 分钟。

组件通过标准的 Input 和 Output 进行操作,并不直接访问 store.

import { Component, Input } from '@angular/core';import { Book } from '../models/book';@Component({  selector: 'bc-book-authors',  template: `    
Written By:
{
{ authors | bcAddCommas }}
`, styles: [` h5 { margin-bottom: 5px; } `]})export class BookAuthorsComponent { @Input() book: Book; get authors() { return this.book.volumeInfo.authors; }}

import { Component, Input, Output, EventEmitter } from '@angular/core';import { Book } from '../models/book';@Component({  selector: 'bc-book-detail',  template: `    
{
{ title }}
{
{ subtitle }}

`, styles: [` :host { display: flex; justify-content: center; margin: 75px 0; } md-card { max-width: 600px; } md-card-title-group { margin-left: 0; } img { width: 60px; min-width: 60px; margin-left: 5px; } md-card-content { margin: 15px 0 50px; } md-card-actions { margin: 25px 0 0 !important; } md-card-footer { padding: 0 25px 25px; position: relative; } `]})export class BookDetailComponent { /** * Presentational components receieve data through @Input() and communicate events * through @Output() but generally maintain no internal state of their * own. All decisions are delegated to 'container', or 'smart' * components before data updates flow back down. * * More on 'smart' and 'presentational' components: https://gist.github.com/btroncone/a6e4347326749f938510#utilizing-container-components */ @Input() book: Book; @Input() inCollection: boolean; @Output() add = new EventEmitter
(); @Output() remove = new EventEmitter
(); /** * Tip: Utilize getters to keep templates clean */ get id() { return this.book.id; } get title() { return this.book.volumeInfo.title; } get subtitle() { return this.book.volumeInfo.subtitle; } get description() { return this.book.volumeInfo.description; } get thumbnail() { return this.book.volumeInfo.imageLinks.smallThumbnail; }}

 

转载地址:http://khljl.baihongyu.com/

你可能感兴趣的文章
微信新增视频传输 互联通讯或迎二次革命
查看>>
tornado和subprocess实现程序的非堵塞异步处理
查看>>
Ubuntu 10.04 安装配置手记 (2010-05-06 13:50)
查看>>
VIEW层AJAX提交表单到Controller的实体(AJAX传递序列化的输入元素)
查看>>
[转] vsftpd文件配置
查看>>
第十三章: User Defaut
查看>>
表变量在存储过程或sql server中的运用
查看>>
【object-c基础】Object-c基础之一:#import,NSLog(),数据类型
查看>>
tablediff同步
查看>>
C#定义属性-只读属性
查看>>
小小聊天室
查看>>
几个不错的网站
查看>>
postmaster.c 中的 ListenAddresses
查看>>
.NET_.NET 发布(publish)网站_01-2
查看>>
文件处理
查看>>
c# 读写 xml
查看>>
使用<frameset><frame/><frame/></frameset> 布局页面 (div+css布局 和frameset布局,两种并列策略)...
查看>>
RDLC子报表
查看>>
2012-09-03 → 2012-09-09 周总结
查看>>
通过设置nginx的client_max_body_size解决nginx+php上传大文件的问题
查看>>