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. underscorejs-shuffle学习

    2.21 shuffle 2.21.1 语法 _.shuffle(list) 2.21.2 说明 返回一个随机乱序的list副本数组, 使用 Fisher-Yates shuffle 来进行随机乱序. ...

  2. jQuery判断文本框是否为空

    1.引用jQuery库 <script src="/static/js/jquery_v1.6.1.js" type="text/javascript"& ...

  3. webkit report

    %for main_o in objects: <% print main_o.sale_announcement_ids %> %for o in announcement_pool.b ...

  4. TWIG整合

    //数字格式化 {{ (p.oldprice * p.count)|number_format(2,'.',',') }}

  5. Hibernate 框架的配置之一

    1. 下载hibernate distribution 3.6.* final包 2. 解压zip包 3. 将lib目录下jpa和required目录下的jar包都拷贝到自己工程的WEB-INF目录下 ...

  6. 修改weblogic jvm启动参数

    进入: D:\Oracle\Middleware\user_projects\domains\base_domain\startWebLogic.cmd 在call 上一行增加: set USER_M ...

  7. 2014年Facebook的开源成就

    2014是Facebook开源硕果丰硕的一年,其开源项目经理詹姆斯·皮尔斯(James Pearce)连续12天发布开源博客文章展示全年该社交网站在此领域取得的成就. 皮尔斯公布的成就包括以下内容: ...

  8. Truck History(poj 1789)

    Description Advanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for v ...

  9. Eclipse控制台中文乱码

    换了OS真是,主要就是对Eclipse的配置操作不熟悉.用着不顺手.源文件一直都是按照google java style的做法保存为UTF-8.现在显示乱码,就得改Eclipse解码的配置为 UTF- ...

  10. LA3353

    感觉好久没做网络流这类的题目都不快会做了 网络流建模之前首先要分析性质 选择要求每个点恰属一个环就代表每个点在选择的图中,只有唯一入度和唯一出度 那就简单了,对n个点拆点,对于原图的边i-->j ...