[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 ...
随机推荐
- 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 ...
- HTML用法小摘录
一.网页地址栏上小图标标签添加写法: <link rel="Shortcut Icon" href="~/Content/ico/glasses.ico" ...
- MAC OSX使用篇
前述: 从windows平台切换到osx平台,的确没能一下子适应过来,在使用过程当中遇到了很多问题. link1:osx卸载应用程序的四种方法 link2:(推荐看)开始使用Mac OS X——写给M ...
- 【技术贴】第二篇 :解决使用maven jetty启动后无法加载修改过后的静态资源
之前写过第一篇:[技术贴]解决使用maven jetty启动后无法加载修改过后的静态资源 一直用着挺舒服的,直到今天,出现了又不能修改静态js,jsp等资源的现象.很是苦闷. 经过调错处理之后,发现是 ...
- 【技术贴】解决使用maven jetty启动后无法加载修改过后的静态资源
如何使用jetty自动热部署修改后的所有文件,比如js,jpg,class等,哇咔咔 太爽啦比tomcat舒服多了. jetty模式是不能修改js文件的,比如你现在调试前端js,发现在myeclips ...
- 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 ...
- 【Java】Java XML 技术专题
XML 基础教程 XML 和 Java 技术 Java XML文档模型 JAXP(Java API for XML Parsing) StAX(Streaming API for XML) XJ(XM ...
- BZOJ1631: [Usaco2007 Feb]Cow Party
1631: [Usaco2007 Feb]Cow Party Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 459 Solved: 338[Submit ...
- OC中的野指针(僵尸指针)
涉及到内存管理问题的都是类类型的变量,而在OC中我们操纵这些对象都是通过操纵指向他们的指针来完成的,一致很多时候会忽略指针存在.比如定义UIView * view = [[UIView alloc]i ...
- 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 ...