[Angular 2] Exposing component properties to the template
Showing you how you can expose properties on your Controller to access them using #refs inside of your template.
// letterSelect.ts import {Component, View, FORM_DIRECTIVES, NgFor} from 'angular2/angular2'; @Component({
selector: 'letter-select'
})
@View({
directives: [NgFor,FORM_DIRECTIVES],
template: `
<select [(ng-model)]="selectedLetter">
<option *ng-for="#letter of letters">{{letter}}</option>
</select>
`
}) export class LetterSelect {
letters: string[] = ['e', 's', 'w'];
selectedLetter: string = 'e';
constructor() { }
}
todoList.ts
import {Component, View, NgFor, FORM_DIRECTIVES} from 'angular2/angular2';
import {TodoService} from './todoService';
import {TodoItemRender} from './todoItemRender';
import {StartsWith} from './startsWith';
import {LetterSelect} from './letterSelect'; @Component({
selector: 'todo-list'
})
@View({
pipes: [StartsWith],
directives: [NgFor, TodoItemRender, FORM_DIRECTIVES, LetterSelect],
template: `
<div>
<todo-item-render
*ng-for="#todo of todoService.todos | startsWith:'title':letterSelect.selectedLetter"
[todoinput]="todo"
>
</todo-item-render>
<letter-select #letter-select></letter-select>
</div>
`
}) export class TodoList{
constructor(
public todoService:TodoService
){ }
}
[Angular 2] Exposing component properties to the template的更多相关文章
- Exploring the Angular 1.5 .component() method
Angular 1.5 introduced the .component() helper method, which is much simpler than the.directive() de ...
- [Angular] Test Container component with async provider
The main idea for testing contianer component is to make sure it setup everythings correctlly. Call ...
- Angular(二) - 组件Component
1. 组件Component示例 2. Component常用的几个选项 3. Component全部的选项 3.1 继承自@Directive装饰器的选项 3.2 @Component自己特有的选项 ...
- [AngularJS] Exploring the Angular 1.5 .component() method
Angualr 1.4: .directive('counter', function counter() { return { scope: {}, restrict: 'EA', transclu ...
- ES6, Angular,React和ABAP中的String Template(字符串模板)
String Template(字符串模板)在很多编程语言和框架中都支持,是一个很有用的特性.本文将Jerry工作中使用到的String Template的特性做一个总结. ES6 阮一峰老师有一个专 ...
- 【Angular】No component factory found for ×××.
报错现象: 用modal打开某个组件页面时报错 报错:No component factory found for UpdateAuthWindowComponent. Did you add it ...
- Library Component Properties的表格如何填写
- [Angular 2] Component relative paths
Oingial aritial --> Link Take away: import { Component, OnInit } from '@angular/core'; @Component ...
- [Angular & Unit Testing] Testing a RouterOutlet component
The way to test router componet needs a little bit setup, first we need to create a "router-stu ...
随机推荐
- IoC模式(控制反转)(转)
转自:http://www.cnblogs.com/qqlin/archive/2012/10/09/2707075.html,写的很好,用C#代码解释控制反转,然后更进一步,提到依赖注入是控制反转的 ...
- bootstrap学习--模态弹出框modals轮子
1.点击按钮型 <link rel="stylesheet" href="lib/bootstrap/css/bootstrap.min.css"> ...
- php之分页类代码
/* 思路 1.把地址栏的URL获取 2.分析URL中的query部分--就是?后面传参数的部分 3.query部分分析成数组 4.把数组中的page单元,+1,-1,形成2个新的数组 5.再把新数组 ...
- 使用Thinkphp框架开发移动端接口
本文给大家分享的是使用thinkphp框架开发移动端接口的2种方法,一种是开发API,另外一种是实现移动端访问自动切换移动主题模板,从而实现伪app访问,下面我们就来详细看下如何实现吧. 方案一:给 ...
- jquery 实现的一款超简单的图片切换功能
<html><head> <meta http-equiv="Content-Type" content="text/html; chars ...
- Adobe Photoshop CS或者CC卸载不了怎么办?
有木有没有遇到这个问题的同学?使用Adobe Creative Suite CleanerToo工具下载就好了~ 下载地址:http://pan.baidu.com/s/1pJ3aBsn
- go bufio
1 bufio 读结构 type Reader struct { buf []byte // 缓冲区 rd io.Reader // read ...
- ZT: WEB学习资料
根据个人经验整理一些Web开发的一些技术书籍,希望对需要进入Web开发领域的TX有所指导,由于是在家里整理的,所有每本书对应的豆瓣链接打不开,如果整理有缺陷请多多指出. 入门篇:通过相关技术的全面基础 ...
- SharePoint Designer cannot open site error " the server could not complete your request"
3.SPD cannot open site, in the log :Error when open web service: System.InvalidOperationException: A ...
- ROR入门之旅
mac上为了不在登录画面看到其他账户,我禁用了root账户,而每次用Terminal的时候,先获得sudo账户的权限: sudo -s mac本身就安装有ruby ruby -v 查看当前安装的rub ...