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的更多相关文章

  1. Exploring the Angular 1.5 .component() method

    Angular 1.5 introduced the .component() helper method, which is much simpler than the.directive() de ...

  2. [Angular] Test Container component with async provider

    The main idea for testing contianer component is to make sure it setup everythings correctlly. Call ...

  3. Angular(二) - 组件Component

    1. 组件Component示例 2. Component常用的几个选项 3. Component全部的选项 3.1 继承自@Directive装饰器的选项 3.2 @Component自己特有的选项 ...

  4. [AngularJS] Exploring the Angular 1.5 .component() method

    Angualr 1.4: .directive('counter', function counter() { return { scope: {}, restrict: 'EA', transclu ...

  5. ES6, Angular,React和ABAP中的String Template(字符串模板)

    String Template(字符串模板)在很多编程语言和框架中都支持,是一个很有用的特性.本文将Jerry工作中使用到的String Template的特性做一个总结. ES6 阮一峰老师有一个专 ...

  6. 【Angular】No component factory found for ×××.

    报错现象: 用modal打开某个组件页面时报错 报错:No component factory found for UpdateAuthWindowComponent. Did you add it ...

  7. Library Component Properties的表格如何填写

  8. [Angular 2] Component relative paths

    Oingial aritial --> Link Take away: import { Component, OnInit } from '@angular/core'; @Component ...

  9. [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 ...

随机推荐

  1. javascript——迭代方法

    <script type="text/javascript"> //五个迭代方法 都接受两个参数:要在每一项上运行的函数 和 运行该函数的作用域(可选) //every ...

  2. 关于jQuery的cookies插件2.2.0版设置过期时间的说明

    欢迎转载,转载请注明作者RunningOn jQuery应该是各位用JavaScript做web开发的常用工具了,它有些插件能非常方便地操作cookie. 不过非常让人郁闷的是,网上几乎所有人对于这些 ...

  3. Mvvm绑定datagrid或listview的selectItems的方法[转]

    单选,很简单,将SelectedItem与ViewModel的属性进行双向绑定就OK了 多选,由于ListView的SelectedItems不能进行绑定,需要将ListView的SelectionC ...

  4. [转] 翻译-高质量JavaScript代码书写基本要点 ---张鑫旭

    by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=1173 原文作者:St ...

  5. 谈谈 jQuery 中的防冲突(noConflict)机制

    许多的 JS 框架类库都选择使用 $ 符号作为函数或变量名,jQuery 是其中最为典型的一个.在 jQuery 中,$ 符号只是 window.jQuery 对象的一个引用,因此即使 $ 被删除,w ...

  6. opencv 2.46与visual studio 2012 配置方法

    一开学就搞实训,还是没学过的图像处理.痛苦啊!图像处理时一般使用Matlab中的图像工具箱,或者是C/C++和OpenCV结合使用.以前看过一些关于opencv的文章,没想到现在要用上了. 把搭建开发 ...

  7. How to solve "The specified service has been marked for deletion" error

    There may be several causes which lead to the service being stuck in “marked for deletion”. Microsof ...

  8. Sequence《优先队列》

    Description Given m sequences, each contains n non-negative integer. Now we may select one number fr ...

  9. 图解linux下top命令的使用

    top命令经常用来监控linux的系统状况,比如cpu.内存的使用,程序员基本都知道这个命令,但比较奇怪的是能用好它的人却很少,例如top监控视图中内存数值的含义就有不少的曲解. 本文通过一个运行中的 ...

  10. hihoCoder 1391 Countries 【预处理+排序+堆】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2016)网络赛)

    #1391 : Countries 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 There are two antagonistic countries, countr ...