Showing you how you can expose properties on your Controller to access them using #refs inside of your template.

  1. // letterSelect.ts
  2.  
  3. import {Component, View, FORM_DIRECTIVES, NgFor} from 'angular2/angular2';
  4.  
  5. @Component({
  6. selector: 'letter-select'
  7. })
  8. @View({
  9. directives: [NgFor,FORM_DIRECTIVES],
  10. template: `
  11. <select [(ng-model)]="selectedLetter">
  12. <option *ng-for="#letter of letters">{{letter}}</option>
  13. </select>
  14. `
  15. })
  16.  
  17. export class LetterSelect {
  18. letters: string[] = ['e', 's', 'w'];
  19. selectedLetter: string = 'e';
  20. constructor() {
  21.  
  22. }
  23. }

todoList.ts

  1. import {Component, View, NgFor, FORM_DIRECTIVES} from 'angular2/angular2';
  2. import {TodoService} from './todoService';
  3. import {TodoItemRender} from './todoItemRender';
  4. import {StartsWith} from './startsWith';
  5. import {LetterSelect} from './letterSelect';
  6.  
  7. @Component({
  8. selector: 'todo-list'
  9. })
  10. @View({
  11. pipes: [StartsWith],
  12. directives: [NgFor, TodoItemRender, FORM_DIRECTIVES, LetterSelect],
  13. template: `
  14. <div>
  15. <todo-item-render
  16. *ng-for="#todo of todoService.todos | startsWith:'title':letterSelect.selectedLetter"
  17. [todoinput]="todo"
  18. >
  19. </todo-item-render>
  20. <letter-select #letter-select></letter-select>
  21. </div>
  22. `
  23. })
  24.  
  25. export class TodoList{
  26. constructor(
  27. public todoService:TodoService
  28. ){
  29.  
  30. }
  31. }

[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. Apache:To Config The Vhost of Django Project

    It is not a good idea to use dev server in Production Environment. Apache or Nginx are good choice.B ...

  2. HTML用法小摘录

    一.网页地址栏上小图标标签添加写法: <link rel="Shortcut Icon" href="~/Content/ico/glasses.ico" ...

  3. MAC OSX使用篇

    前述: 从windows平台切换到osx平台,的确没能一下子适应过来,在使用过程当中遇到了很多问题. link1:osx卸载应用程序的四种方法 link2:(推荐看)开始使用Mac OS X——写给M ...

  4. 【技术贴】第二篇 :解决使用maven jetty启动后无法加载修改过后的静态资源

    之前写过第一篇:[技术贴]解决使用maven jetty启动后无法加载修改过后的静态资源 一直用着挺舒服的,直到今天,出现了又不能修改静态js,jsp等资源的现象.很是苦闷. 经过调错处理之后,发现是 ...

  5. 【技术贴】解决使用maven jetty启动后无法加载修改过后的静态资源

    如何使用jetty自动热部署修改后的所有文件,比如js,jpg,class等,哇咔咔 太爽啦比tomcat舒服多了. jetty模式是不能修改js文件的,比如你现在调试前端js,发现在myeclips ...

  6. JavaScript Application Architecture On The Road To 2015

    JavaScript Application Architecture On The Road To 2015 I once told someone I was an architect. It’s ...

  7. 【Java】Java XML 技术专题

    XML 基础教程 XML 和 Java 技术 Java XML文档模型 JAXP(Java API for XML Parsing) StAX(Streaming API for XML) XJ(XM ...

  8. BZOJ1631: [Usaco2007 Feb]Cow Party

    1631: [Usaco2007 Feb]Cow Party Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 459  Solved: 338[Submit ...

  9. OC中的野指针(僵尸指针)

    涉及到内存管理问题的都是类类型的变量,而在OC中我们操纵这些对象都是通过操纵指向他们的指针来完成的,一致很多时候会忽略指针存在.比如定义UIView * view = [[UIView alloc]i ...

  10. HDU 5873 Football Games 【模拟】 (2016 ACM/ICPC Asia Regional Dalian Online)

    Football Games Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...